0

am Having Custom Field named as thumb.i want to show the images using these custom fields.i want to be fix the image size.

My code is

 <img class="thumb" src="<?php echo get_post_meta($post->ID, 'thumb', true) ?>" alt="<?php the_title(); ?>" />

i tried timthumb also like this

 <img class="thumb" timthumb.php?src="<?php echo get_post_meta($post->ID, 'thumb', true) ?>"&q=100 alt="<?php the_title(); ?>" />

any one help me. thanks in advance.

1

You'd be better off using the inbuilt Post Thumbnails, which were introduced in WordPress 2.9 - these are easier to use than custom fields and have things like sizing built in.

Once you've enabled Post Thumbnails, you can set their default size using set_post_thumbnail_size and then use them in your theme with the_post_thumbnail

  • you are right @:tallphil,am familiar in that.Here i want to take the images from outside of my website.so only i used custom field.here post thumbnails is not working.i gave the direct link of the images in my custom field.thanks for your try... – Ramkumar M Sep 13 '11 at 10:53
  • ok, in that case timthumb is probably your best bet. You had some errors in the HTML markup posted above, I've described them in a separate answer below... – tallphil Sep 13 '11 at 11:18
1

You have an error in the second (timthumb) code. The src= was after the tumthumb.php instead of before, plus the " should be after the &q=100. It should be:

<img class="thumb" src="timthumb.php?<?php echo get_post_meta($post->ID, 'thumb', true); ?>&q=100" alt="<?php the_title(); ?>" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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