Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a custom field called picture. On the media settings page I've set thumbnail size to 100x100. If upload an image called gecko.jpg, Wordpress automatically resizes it and generates gecko-100x100.jpg. I want to use both the thumbnail size and original size, is it possible?

With <?php echo get_post_meta($post->ID, 'picture', true); ?> I can only get the original size.

Can anybody please assist me?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

can you explain why do you need custom fields ? (personally i think they are HUGELY over-used.. especially for images )

if there is no specific reason why you need it , you could use the the_post_thumbnail(); function .

like so :

the_post_thumbnail('thumbnail');       // Thumbnail (default 150px x 150px max)
the_post_thumbnail('medium');          // Medium resolution (default 300px x 300px max)
the_post_thumbnail('large');           // Large resolution (default 640px x 640px max)
the_post_thumbnail('full'); 

all you have to do , is when you upload your image - define it as "featured image"

(first check if your functions.php file has this line: add_theme_support('post-thumbnails'); and if not - then add it .

if you want to go further and add some more custom sizes , you can add also this :

set_post_thumbnail_size( 150, 230, true ); // Normal default post thumbnails
add_image_size( 'single-post-thumbnail', 400, 9999 ); // Permalink thumbnail size
add_image_size( 'example_name_2', 100, 100, false ); // example_name_2 thumbnail size
add_image_size( 'example_name_3', 50, 50, true ); // example_name_3  thumbnail size

etc.. et.. you can add as many as you like, and then call them like :

the_post_thumbnail('example_name_2');

(newbie note - all the above code should be placed in functions.php file. the function call the_post_thumbnail(); is to be places inside the loop.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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