Site logo

Archived topic

Replace featured image with video

5 replies · Started by Mark on December 28, 2017

Viewing posts 1–6 of 6

Hello,

I would like to replace featured images with videos. I've tried Featured Video Plus but it's not working the way I want it to, so I'm building a custom solution.

I've created a custom field for the video link 'video_url' and I want to replace the whole post-thumbnail code with this code:
'<video class="featured-video" src="(link from video-url)" autoplay loop muted playsinline ></video>'

Can you help me with php code?

With Featured Video Plus set at autoplay+loop, only one video at the time is playing. I want to replace gifs with mp4 videos and have more videos looping at one time.

You could try using this filter: generate_featured_image_output

For example:

add_filter( 'generate_featured_image_output', 'tu_custom_featured_image' );
function tu_custom_featured_image( $output ) {
    if ( get_post_meta( get_the_ID(), '_your_id', true ) ) {
        return 'your code';
    } else {
        return $output;
    }
}

Thank Tom!

It's working, you are amazing!

Glad I could help! :)

This archived topic is closed to new replies.