if/else for Custom Thumbnail and TimThumb
-
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="https://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 }; ?>
- The topic ‘if/else for Custom Thumbnail and TimThumb’ is closed to new replies.