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)

Rishihuptech
Shopify Partner
642 118 129

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
9550 1194 1532

@amrhassan - is video format other than mp4?

Support me | To build shopify pages use pagefly | You are welcome to 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
9550 1194 1532

@amrhassan - can you share that video link?

Support me | To build shopify pages use pagefly | You are welcome to contact me - suyash.patankar@gmail.com , My timezone is GMT+5:30.

Small_Task_Help
Shopify Partner
528 16 36

Hi,

 

You can try video from Youtube

Click here to Contact and Get Shopify Store Help
E-mail - hi@ecommercesmalltask.com
We are Shopify Experts   from Ecommerce Small Task Company.
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
528 16 36

https://community.shopify.com/c/shopify-discussions/how-to-add-my-own-video-to-product-page-not-yout...

Click here to Contact and Get Shopify Store Help
E-mail - hi@ecommercesmalltask.com
We are Shopify Experts   from Ecommerce Small Task Company.
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.

Rishihuptech
Shopify Partner
642 118 129

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.