flynt-starter-theme icon indicating copy to clipboard operation
flynt-starter-theme copied to clipboard

SliderMedia Component - Partials Logic

Open BiOZed opened this issue 8 years ago • 1 comments

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 ?

BiOZed avatar Jul 07 '17 17:07 BiOZed

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 %}

dgrdl avatar Jul 17 '17 16:07 dgrdl