flynt-starter-theme
flynt-starter-theme copied to clipboard
SliderMedia Component - Partials Logic
The Image and OembedVideo partials are working differently. The Image accesses the image using mediaSlide.image.src, while the OembedVideo only has access to the mediaSlider.image because of the only parameter in the include statemnt.
I believe the two partials should loaded the same way. Any thoughts on which way would make most sense ?
I agree. I would go with the shorter, non-nested variables and add the only statement to the parent. My reasoning is that a partial should not have to depend on the variable naming and structure of the parent.
So, how about something like this?
{% if mediaSlide.mediaType == 'image' %}
{% include 'Partials/Image/index.twig' with {'image': mediaSlide.image } only %}
{% elseif mediaSlide.mediaType == 'oembed' %}
{% include 'Partials/OembedVideo/index.twig' with {'posterImage': mediaSlide.image, 'oembedLazyLoad': mediaSlide.oembedLazyLoad } only %}
{% endif %}
{% include 'Partials/SlideTitle/index.twig' with {'titleText': mediaSlide.titleText } only %}