Video doesn't show - placeholder instead

Solved

Video doesn't show - placeholder instead

amrhassan
Shopify Partner
31 1 1

A video section when selecting the video from shopify host, it appears probably in the theme customizations, but when I publish or preview, the placeholder appears instead. Can anyone help with that issue?
Here's the code used in video.liquid template:

{% liquid
                assign video_url = ''
                for source in section.settings.shopify_video.sources
                  assign format = source.url | slice: -4, 4
                  if format == ".mp4"
                    assign video_url = source.url
                  endif
                endfor
                assign placeholder_video = 'https://cdn.shopify.com/videos/c/o/v/fbb140fd46e3429eba459e1549dbbe38.mp4'
        
                if video_url == blank
                  assign video_url = placeholder_video
                endif
              %}
              <video 
                src="{{ video_url }}"
                playsinline
                {% if section.settings.show_controls %}
                controls
                {% endif %}
                {% if section.settings.loop %}loop{% endif %}
                {% if section.settings.muted %}
                  muted
                  {% if section.settings.autoplay %} autoplay{% endif %}
                {% endif %}
                >
              </video>
            {%- endif -%}

I am using minimog theme.

Accepted Solution (1)

Huptech-Web
Shopify Partner
1115 218 246

This is an accepted solution.

Hi @amrhassan 

 

I have updated the code and it is working I have checked it on test store, Check the snippet below

{% assign video_url = '' %}

{% assign video_url = section.settings.shopify_video.sources[1].url %}

{% assign placeholder_video = 'https://cdn.shopify.com/videos/c/o/v/fbb140fd46e3429eba459e1549dbbe38.mp4' %}

{% if video_url == blank %}
  {% assign video_url = placeholder_video %}
{% endif %}
<video
  src="{{ video_url }}"
  playsinline
  {% if section.settings.show_controls %}
    controls
  {% endif %}
  {% if section.settings.loop %}
    loop
  {% endif %}
  {% if section.settings.muted %}
    muted
    {% if section.settings.autoplay %} autoplay{% endif %}
  {% endif %}
></video>

 

If you found this response helpful, please do like and accept the solution. Thanks!
Need support with Customizing your Shopify store?
Feel free to contact me at info@huptechweb.com or Visit our website Huptech Web.
Instant Shortcode Builder: Integrate customizable UI features anywhere in your store - No coding knowledge required

View solution in original post

Replies 9 (9)

suyash1
Shopify Partner
10700 1321 1698

@amrhassan - is video format other than mp4?

Support me | To build shopify pages use PAGEFLY | Contact me - suyash.patankar@gmail.com , My timezone is GMT+5:30.
amrhassan
Shopify Partner
31 1 1

No, it's mp4

suyash1
Shopify Partner
10700 1321 1698

@amrhassan - can you share that video link?

Support me | To build shopify pages use PAGEFLY | Contact me - suyash.patankar@gmail.com , My timezone is GMT+5:30.

Small_Task_Help
Shopify Partner
884 29 79

Hi,

 

You can try video from Youtube

To Get Shopify Experts Help, E-mail - hi@ecommercesmalltask.com
About Us - We are Shopify Expert India
At Google My Business - Ecommerce Small Task - Hire Shopify Developers Ahmedabad
amrhassan
Shopify Partner
31 1 1

A video from youtube works fine but I need to show a specific video hosted on shopify not youtube.

Small_Task_Help
Shopify Partner
884 29 79
amrhassan
Shopify Partner
31 1 1

I have already seen this post, this solution will ruin my section settings. I want to fix the code to work fine with the other section settings.

Huptech-Web
Shopify Partner
1115 218 246

This is an accepted solution.

Hi @amrhassan 

 

I have updated the code and it is working I have checked it on test store, Check the snippet below

{% assign video_url = '' %}

{% assign video_url = section.settings.shopify_video.sources[1].url %}

{% assign placeholder_video = 'https://cdn.shopify.com/videos/c/o/v/fbb140fd46e3429eba459e1549dbbe38.mp4' %}

{% if video_url == blank %}
  {% assign video_url = placeholder_video %}
{% endif %}
<video
  src="{{ video_url }}"
  playsinline
  {% if section.settings.show_controls %}
    controls
  {% endif %}
  {% if section.settings.loop %}
    loop
  {% endif %}
  {% if section.settings.muted %}
    muted
    {% if section.settings.autoplay %} autoplay{% endif %}
  {% endif %}
></video>

 

If you found this response helpful, please do like and accept the solution. Thanks!
Need support with Customizing your Shopify store?
Feel free to contact me at info@huptechweb.com or Visit our website Huptech Web.
Instant Shortcode Builder: Integrate customizable UI features anywhere in your store - No coding knowledge required
amrhassan
Shopify Partner
31 1 1

It worked!!! Thank you so much.