Developer Hooks

Our Featured Videos plugin for WooCommerce comes with developer hooks that may help you programmatically setup the plugin.

Programatically set video settings

You normally set each featured image per product while editing said product. Incase you want to apply the settings programmatically in bulk, or per product, you can use the featured_videos_filter_single_product_settings. The filter overrides the featured video settings on all products or on a per product basis. If you don’t need to change anything, just return the default $settings array unchanged.

function puri_featured_video_custom_settings( $settings, $product_id ) { // Our settings look like this for reference. Don't create a new array, only override each key. // $settings = array( // 'source' => false, // 'external_url' => '', // 'self_hosted_url' => '', // 'loop' => false, // 'autoplay' => false, // 'mute' => false, // 'thumbnail_url' => false, // 'poster_url' => false, // ); $settings['source'] = 'external'; // For embedded videos. $settings['source'] = 'self_hosted'; // For Self Hosted videos $settings['loop'] = true; return $settings; } add_filter( 'featured_videos_filter_single_product_settings', 'puri_featured_video_custom_settings', 10, 2 );
Code language: PHP (php)

Change the default thumbnail image

Incase there isn’t a YouTube or a pre-selected thumbnail then we’ve included a simple default thumbnail. It’s a black image with a faded play button. If you wish to use your own default thumbnail then you can change it with the featured_videos_filter_default_thumbnail filter. You will need to have the new thumbnail image accessable somewhere on your server. Replace the example image path with your own.

function puri_featured_video_custom_thumbnail( $thumbnail_url, $product_id ) { $thumbnail_url = 'https://mysite.com/custom-thumbnail.png'; return $thumbnail_url; } add_filter( 'featured_videos_filter_default_thumbnail', 'puri_featured_video_custom_thumbnail', 10, 2 );
Code language: PHP (php)
Was this page helpful?