Title: Multiple Custom Thumbnails
Last modified: August 22, 2016

---

# Multiple Custom Thumbnails

 *  Resolved [Simon Barnett](https://wordpress.org/support/users/simbasounds/)
 * (@simbasounds)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/multiple-custom-thumbnails/)
 * Hi Frank,
 * Long time. Hope you’re well : )
 * We were discussing thumbnails in [this thread](https://wordpress.org/support/topic/hqthumb1-not-reflecting-on-playlists-in-custom-fields?replies=11).
 * Now that you have lyte_match_thumburl in the plugin, perhaps you can help me 
   get my head around how to use it to implement multiple thumbnails associated 
   with multiple videos on a page.
 * The only way I can think of this working is having the thumb url as an argument
   in the shortcode to associate it with the correct video, which would probably
   mean a bit of hacking the plugin.
 * But perhaps there’s a different and / or better way that you know of?
 * Many thanks
 * [https://wordpress.org/plugins/wp-youtube-lyte/](https://wordpress.org/plugins/wp-youtube-lyte/)

Viewing 14 replies - 1 through 14 (of 14 total)

 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/multiple-custom-thumbnails/#post-5907392)
 * Afternoon Simon;
    Well, I would store the custom thumbnail(s) in custom field(
   s) of the blogpost (custom fields can be set in the post editor) as a key-value
   pair, e.g. lyte_iECeetxtm0g (which contains the ID of the vid) as key and [http://upload.wikimedia.org/wikipedia/commons/5/5e/The_Bad_Plus_(Ethan_Iverson,_Reid_Anderson,_David_King)](http://upload.wikimedia.org/wikipedia/commons/5/5e/The_Bad_Plus_(Ethan_Iverson,_Reid_Anderson,_David_King)).
   jpg as value (the alternate image).
 * Then I would add hook a function to the lyte_match_thumburl filter and check 
   the custom field for the URL to use for that video (or video’s, if you have more
   then one in a post) based on the key (lyte_iECeetxtm0g).
 * That should just work 🙂
 * hope this helps,
    frank
 *  Thread Starter [Simon Barnett](https://wordpress.org/support/users/simbasounds/)
 * (@simbasounds)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/multiple-custom-thumbnails/#post-5907394)
 * That sounds like the one! Thanks, Frank.. will try it out.
 *  Thread Starter [Simon Barnett](https://wordpress.org/support/users/simbasounds/)
 * (@simbasounds)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/multiple-custom-thumbnails/#post-5907527)
 * Hello again, Frank.
 * For videos added to posts with httpv, how do I grab the ID of a video just before
   lyte_parse() executes?
 * This would be in order to get the value of the corresponding Custom Field key
   and apply it to the filter.
 * Many thanks
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/multiple-custom-thumbnails/#post-5907528)
 * you could use the “lyte_content_preparse” filter and use a regex to extract httpv-
   urls?
 * but when using “lyte_match_thumburl” you’ll have the URL to the original thumbnail
   as input, which contains the ID, so you could extract it from there, no?
 * frank
 *  Thread Starter [Simon Barnett](https://wordpress.org/support/users/simbasounds/)
 * (@simbasounds)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/multiple-custom-thumbnails/#post-5907529)
 * Perhaps I’m not understanding the filter / function.
 * If I use this in functions.php:
 *     ```
       add_filter('lyte_match_thumburl','lyte_my_own_thumburl');
       function lyte_my_own_thumburl($thumb) {
           return "http://www.kevinlikes.com/wp-content/uploads/2014/09/jonah-745.jpg";
       }
       ```
   
 * It replaces the thumbnails of all videos on a page. But where does the ID go 
   to make it selective?
 * I could do it something like this:
 *     ```
       add_filter('lyte_match_thumburl','lyte_my_own_thumburl');
       function lyte_my_own_thumburl($thumb) {
           $video_id = '_zzrf8KK2FU';
           $video_image = get_post_meta(get_the_id(), $video_id, true);
           return $video_image;
       }
       ```
   
 * I know that’s not complete (needs to step through all custom fields to obtain
   keys), but it’s to explain my other two issues:
 * 1. WordPress doesn’t like _zzrf8KK2FU as a custom field key. Won’t store it.
   
   2. We are already using custom fields for other things on the website, so obtaining
   only the video ID keys gets tricky.
 * So now my thinking is towards using Advanced Custom Fields plugin to create a
   more “dedicated area” for video IDs and thumb URLs.
 * But perhaps I’m going on a tangent when the answer is simpler?
 *  Thread Starter [Simon Barnett](https://wordpress.org/support/users/simbasounds/)
 * (@simbasounds)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/multiple-custom-thumbnails/#post-5907530)
 * “when using “lyte_match_thumburl” you’ll have the URL to the original thumbnail
   as input, which contains the ID”
 *     ```
       add_filter('lyte_match_thumburl','lyte_my_own_thumburl');
       function lyte_my_own_thumburl($thumb) {
           return "http://www.kevinlikes.com/wp-content/uploads/2014/09/jonah-745.jpg";
       }
       ```
   
 * I’m still not understanding where the filter accepts the video ID to link it 
   to the correct video. Sorry if I’m missing something really obvious, Frank.
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/multiple-custom-thumbnails/#post-5907531)
 * Regarding the custom field key; use “lyte_zzrf8KK2FU”?
 * regarding having multiple custom fields; as you have the key (see code below)
   that doesn’t matter (else you could always [get all custom fields in an array](https://codex.wordpress.org/Function_Reference/get_post_custom)(
   or not setting the third value, “single”, to true in get_post_meta) and loop 
   over it).
 * Something like this should work (you’ll have to replace the magic with actual
   magic though);
 *     ```
       add_filter('lyte_match_thumburl','lyte_my_own_thumburl',10,1);
       function lyte_my_own_thumburl($thumb) {
           $video_id="lyte_".magic_to_extract_id_from_thumb($thumb);
           $video_image = get_post_meta(get_the_id(), $video_id, single);
           return $video_image;
       }
       ```
   
 *  Thread Starter [Simon Barnett](https://wordpress.org/support/users/simbasounds/)
 * (@simbasounds)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/multiple-custom-thumbnails/#post-5907532)
 * Thanks Frank, ok let’s take this for a test drive..
 *  Thread Starter [Simon Barnett](https://wordpress.org/support/users/simbasounds/)
 * (@simbasounds)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/multiple-custom-thumbnails/#post-5907534)
 * Can I formulate my question another way? How would I modify the code below:
 *     ```
       add_filter('lyte_match_thumburl','lyte_my_own_thumburl');
       function lyte_my_own_thumburl($thumb) {
           return "http://www.kevinlikes.com/wp-content/uploads/2014/09/jonah-745.jpg";
       }
   
       add_filter('lyte_match_thumburl','lyte_my_other_thumburl');
       function lyte_my_other_thumburl($thumb) {
           return "https://i.ytimg.com/vi/ArqoaJq3fXU/sddefault.jpg";
       }
       ```
   
 * ..to separately target videos added to a post with:
 *     ```
       httpv://www.youtube.com/watch?v=_zzrf8KK2FU
       httpv://www.youtube.com/watch?v=ArqoaJq3fXU
       ```
   
 * ..so the first video has the first thumbnail, and the second video has the second
   thumbnail.
 * I still can’t get my head around how the filter / function actually hooks into
   specific video IDs. How it catches different httpv links at the point at which
   they execute.
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/multiple-custom-thumbnails/#post-5907535)
 * well, the point is that $thumb (coming in as parameter of your lyte_my_own_thumburl-
   function) will automatically hold the default YT thumbnail URL, so you can use
   that to extract the video ID 🙂
 * frank
 *  Thread Starter [Simon Barnett](https://wordpress.org/support/users/simbasounds/)
 * (@simbasounds)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/multiple-custom-thumbnails/#post-5907546)
 * Thanks Frank. Still stumped about how/why that works, but if/when I figure it
   out I’ll post more detail here.
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/multiple-custom-thumbnails/#post-5907547)
 * well, a plugin with a filter typically does;
 *     ```
       $plugin_variable="this is a string";
       $plugin_variable=apply_filter("filter_name",$plugin_variable);
       ```
   
 * when adding a filter to that hook, you’ll get the variable from the plugin as
   input and can do stuff with that:
 *     ```
       add_filter('filter_name','my_filtered_var',10,1);
       function my_filtered_var($in) {
       	return $in." with some text added";
       	}
       ```
   
 * Autoptimize does this for the “lyte_match_thumburl”-hook, providing the filter
   with the default thumbnail URL that contains the video ID, so if you use the 
   string stored in $thumb you should be able to extract the ID 🙂
 * frank
 *  Thread Starter [Simon Barnett](https://wordpress.org/support/users/simbasounds/)
 * (@simbasounds)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/multiple-custom-thumbnails/#post-5907548)
 * ok, and the filter fires every time httpv fires..
    hmm.. ok, I’m learning, and
   appreciate it : )
 *  Plugin Author [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * (@futtta)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/multiple-custom-thumbnails/#post-5907549)
 * > ok, and the filter fires every time httpv fires..
 * yep 🙂

Viewing 14 replies - 1 through 14 (of 14 total)

The topic ‘Multiple Custom Thumbnails’ is closed to new replies.

 * ![](https://ps.w.org/wp-youtube-lyte/assets/icon-128x128.png?rev=1836005)
 * [WP YouTube Lyte](https://wordpress.org/plugins/wp-youtube-lyte/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-youtube-lyte/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-youtube-lyte/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-youtube-lyte/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-youtube-lyte/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-youtube-lyte/reviews/)

## Tags

 * [thumbnails](https://wordpress.org/support/topic-tag/thumbnails/)
 * [thumbs](https://wordpress.org/support/topic-tag/thumbs/)

 * 14 replies
 * 2 participants
 * Last reply from: [Frank Goossens](https://wordpress.org/support/users/futtta/)
 * Last activity: [11 years, 1 month ago](https://wordpress.org/support/topic/multiple-custom-thumbnails/#post-5907549)
 * Status: resolved