Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
  • #5429


    How can i modify the kriesi_post_thumb.php file to load images from a custom field instead of the wordpress featured image function?

    I need to do this because i have a very old website with hundreds of posts, built before wordpress launch of the featured image function, so all the “featured images” urls are stored on a custom field called “image”

    on my previous theme, i used to get the image url using this:

    get_post_meta($this_post, "image", $single = true);

    So i tried using this code on your file kriesi_post_thumb.php:



    $image_src[0] = get_post_meta($this_post, "image", $single = true);

    $image_src2[0] = get_post_meta($this_post, "image", $single = true);




    $image_src = wp_get_attachment_image_src($thumbnail_id, $option[0]);

    $image_src2 = wp_get_attachment_image_src($thumbnail_id, NULL);


    But no success. The images do show up on the site, and the work perfectly on the homepage accordion slider. But on the post thumbnails they are not being resized by timthumb. Plus, an image square gets added to very top of each post content on single.php, which is awful :p

    Can you please help me out???

    Thanks in advance



    the easiest way is to replace following code in kriesi_post_thumb.php:

    if (isset($option['size'][1]))
    $image_customfield = get_post_meta($this_post, $option['size'][1], true);


    if (isset($option['size'][1]))
    $image_customfield = get_post_meta($this_post, $option['size'][1], true);

    if(empty($image_customfield) || get_post_meta($this_post, 'custom_image', true)){
    $image_customfield = get_post_meta($this_post, 'custom_image', true);

    and instead of “custom_image” use your own key :)


    Thanks Dude !! :)

    Your suggestion does work. Images show up in the site But with some problems:

    – Timthumb doesn’t work for images generated this way

    – The images doesn’t get a permalink to the post

    – There are still a square at the very top of each post’s single content

    I managed to figure out the first problem myself, by adding a small modification to your code. So i did it like this:

    if (isset($option['size'][1]))
    $image_customfield = get_post_meta($this_post, $option['size'][1], true);
    if(empty($image_customfield) || get_post_meta($this_post, 'image', true)){
    $image_url = get_post_meta($this_post, 'image', true);
    if($k_option['custom']['resizing'] )
    $parameters .= '&zc=1';
    if($option['wh']['height'] != '') $parameters .= '&h='.$option['wh']['height'] ;
    if($option['wh']['width'] != '') $parameters .= '&w='.$option['wh']['width'] ;
    //check if domain should be included in timthumb output
    if($option['domain'] == false)
    $uri_array = parse_url($image_src[0]);
    $image_src[0] = $uri_array['path'];
    $image_customfield = $option['script'].$image_url.$parameters;

    Now timthumb works great, but i’m still facing the 2 other problems.

    Any suggestion?

    Thanks for all your hard work dude. Really appreciate it. Your the Man!! :)


    Can you post a link to your website please – it helps me to investigate the issues.


    Sure. Here you go:



    Ups. I Just remembered, maintenance mode is on.

    Can i send the login credentials to your email?


    Hey. Me again.

    I was able to solve the link problem :)

    at very bottom of the file, i switched this code:

    $defaultimage = $linkwrap[0]."<img src='".$image_URL."' alt='' title='".get_the_title()."' />".$linkwrap[1];
    return $defaultimage;

    For this code:

    if (!isset($option['size'][1]))
    $linkwrap[0] = '<a href="'.get_permalink().'" title="'.get_the_title().'">';
    $linkwrap[1] = '</a>';

    $defaultimage = $linkwrap[0]."<img src='".$image_URL."' alt='' title='".get_the_title()."' />".$linkwrap[1];
    return $defaultimage;

    Now i only need to figure out the square at the top of the posts :)

    See this screeshot:

    Almost there … lol


    And got the last part :D

    All i did was to comment this portion of code from the single.php file and bingo. Now the theme is fully working for me and my old site .. hehe

    $preview_image = kriesi_post_thumb($post->ID, array('size'=> array('M'),
    'display_link' => array('lightbox'), // '_prev_image_link' or array('lightbox')
    'linkurl' => array ('fullscreen','_preview_big'),
    'wh' => $k_option['custom']['imgSize']['M']

    Thanks for your help ;)


    topic resolved ;)


    Glad that you found the solution :)

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

The topic ‘Custom fields for thumbnails’ is closed to new replies.