I am using a Tube plugin that is creating my posts and pulling in thumbnail images that it is using on the main page to link to the posts. While it is creating and displaying thumbnails these are NOT "Featured Images" however I was hoping that it would be possible to use these thumbs to create a "featured Image" seeing as they are already there and the perfect size etc. Is there a way to drop <?php set_post_thumbnail( $post, $thumbnail_id ); ?> in there somehow or something like that?....

The thumbs are here (this is a network install) wp-content/uploads/sites/2/thumbs

Here is the function it is using. I was hoping that within this function it could also be set as the "Featured Image" for the particular post...

function my_thumb($prefix,$title){

$saved_thmb = get_post_meta( get_the_ID(),'saved_thmb',true);

$subPath = my_sub_dir_path(get_the_ID()); 

$upload_dir = wp_upload_dir();
$thumb_url = $upload_dir[baseurl]."/my-thumbs/".$subPath."/";

  $thumb = $thumb_url."/".get_the_ID()."_1.jpg";
} elseif($saved_thmb>1) {

  $def_thmb = get_post_meta( get_the_ID(),'def_thmb',true);

  $thumb = $thumb_url."/".get_the_ID()."_".$def_thmb.".jpg";


  • That is a multisite install, right?
    – kaiser
    Nov 4, 2014 at 21:38
  • yes that is right should have mentioned that
    – milo99
    Nov 4, 2014 at 21:44

1 Answer 1


While looking at some code for another issue I had a lightbulb went off in my head and brought me back to this problem. So after several tries at it I came up with this...

    function add_image_to_feed( $thumbz){
if( is_feed() ){
    $def_thmb = get_post_meta( get_the_ID(),'def_thmb',true);

    $subPath = tube_sub_dir_path(get_the_ID()); 

    $upload_dir = wp_upload_dir();
    $thumb_ur = $upload_dir[baseurl]."/tube-thumbs/".$subPath."";

    $thumbz = $thumb_ur."/".get_the_ID()."_".$def_thmb.".jpg";

} else {
$thumbz = "<img class=\"img-responsive\" src=\"$thumbz\" >";
return $thumbz;


So now these images are being added directly to my feed which works brilliantly for me. I simply use an RSS plugin to add these thumbs as a featured image. The entire process is now automated I don't need to touch a thing now that it is set.

  • The only issue that remains is that the code does not work when I add it to the functions.php file that I created for the Child Theme. it does work fine for the main functions.php file though.
    – milo99
    Nov 24, 2014 at 20:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.