Support

Account

Home Forums General Issues Render Video from a wordpress shortcode

Solving

Render Video from a wordpress shortcode

  • Hi!
    I’m struggling a lot with this problem. I tried many things but nothing works.
    Let me explain..

    I have a file field (tried array, url and ID) assigned to posts. It is called “video_feature”. The idea is to load a video, so I can render it in a Post grid in my homepage.

    In my oxygen template I tried these codes
    <video width=200 height=300 autoplay muted loop>
    <source src=<?php get_field('video_featured');?> type="video/m4">
    </video>

    also with
    <source src="<?php echo $video_featured; ?>"

    Those don’t work.
    When I call one specific video like this
    <source src=https://example. com/wp-content/uploads/2023/05/video.mp4 "type="video/m4">

    It works, but of course I need a different video for each post, so that’s no good.

    I’m really clueless as to what to try next. Any guidance will be really appreciated. Or if anyone wants to take this simple job, I will be more confident giving credentials here than in Fiverr or the like, where I had several problems in the past.

    Thanks!

  • Finally made it work with this one!

       <?php 
        
        $link_data = get_field('video_featured'); 
    
        if(!empty($link_data))
        { 
        $link = $link_data['url'];  
        
        ?>
    
        
        <video width="200" height="300" playsinline autoplay muted loop disableremoteplayback>
    		
            <source src="<?php echo $link; ?>" type="video/mp4">   
                              
            Your browser does not support the video tag.
        
        </video>
    
    <?php } ?>

    Now trying to set the poster via ACF image field. I will keep updating this thread in case someone needs it.

  • And here with dynamic poster loaded in an image field (return format URL):

    <?php 
        
        $link_data = get_field('video_featured'); 
    $link_poster = get_field('poster_image'); 
    
        if(!empty($link_data))
        { 
        $link = $link_data['url'];  
        
        ?>
    
        
        <video width="200" height="300" playsinline autoplay muted loop disableremoteplayback poster="<?php echo $link_poster; ?>" >
    		
            <source src="<?php echo $link; ?>" type="video/mp4">   
                              
            Your browser does not support the video tag.
        
        </video>
    
    <?php } ?>

    I’m not a developer, just an enthusiast, so if this can be improved please feel free todo so. Meanwhile I’m so happy it works! 😀

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.