• Resolved Uli

    (@uli)


    If anybody can point me in the right direction, can’t seem to find the answer on the forums. Here’s what I am trying to accomplish:

    I have 600 posts that use the value (imagename.jpg) from a custom field “thumb_home_img” to display a thumbnail for the category pages (see code snippet 1 below).

    Now I switched to a theme that uses TimThumb to generate/display thumbnails (see code snippet 2 below), but I don’t want to fix all those legacy posts. How do I create an if/else loop that basically asks:

    “If there’s a value for the custom field “thumb_home_img”, then grab that value and display the thumbnail using code snippet 1. Else use code snippet 2.”

    ANY IDEAS?

    Code Snippet 1:
    <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><img src="http://media.skinnychef.com/thumbs/<?php echo get_post_meta($post->ID, "thumb_home_img", $single = true); ?>" alt="<?php the_title(); ?>" /></a>

    Code Snippet 2:

    <?php $thumb = '';
    $width = get_option('thecorporation_thumbnail_width_usual');
    $height = get_option('thecorporation_thumbnail_height_usual');
    $classtext = 'thumbnail-post alignleft';
    $titletext = get_the_title();
    
    $thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext);
    $thumb = $thumbnail["thumb"];
    ?>
    
    <?php if($thumb <> '' && get_option('thecorporation_thumbnails_index') == 'on') { ?>
    <a>" title="<?php printf(__ ('Permanent Link to %s', 'TheCorporation'), $titletext) ?>">
    <?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext , $width, $height, $classtext); ?>
    </a>
    <?php }; ?>

Viewing 1 replies (of 1 total)
  • Thread Starter Uli

    (@uli)

    Never mind, I came up with my own solution.

    – uploaded all thumbs from the previous directory to the one that I have in use for TimThumb
    – exported the wp_postmeta table via PHPmyadmin, and globally search/replaced both the field name and its URL value

Viewing 1 replies (of 1 total)
  • The topic ‘if/else for Custom Thumbnail and TimThumb’ is closed to new replies.