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 post type which contains custom fields for uploading images of different types for a portfolio site. For example: (logos, websites, print-ads, etc...).

I plan on uploading images of all different sizes and aspect ratios, but I need to have a smaller size (thumbnail) of a specific (and different) size for each image type. I also need functionality to crop these thumbnails manually.

Logo thumbs -> 200x200

Website thumbs -> 450x200

print-ad thumbs -> 200X400 etc...

I've been toying with a couple plugins: Post Thumbnail Editor, Multiple Post Thumbnails; but these seem to be buggy in WP-3.3 and they don't appear to do exactly what I want anyway

I can, of course, just upload 2 different versions of each image, and use the crop tool in the backend to get them to the right size, but I would love a more elegant approach.

So I guesse what I am really looking for is some advice.

  • Should I keep fighting with existing plugins and try to get something working?
  • Should I try to develop my own? (I'm pretty decent with php/javascript but have only written extremely simple wp plugins as of yet)?
  • Should I give up and use the dirty (upload 2 versions of each) approach?

I would be willing to spend the weekend on it (10-15 hours) if need be.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Add this code to your functions.php

if(function_exists('add_theme_support'))
add_theme_support('post-thumbnails');

// Set the thumbnail size
add_image_size('custom_logo', 200, 200, true );
add_image_size('custom_website_thumb', 450, 200, true );
add_image_size('custom_print_ad_thumb', 200, 400, true );

Put this in your post template where you want to see the image.

<?php echo get_the_post_thumbnail($post_id, 'custom_logo'); ?>

You can also wrap it in a link like this.

 <a href="<?php echo get_permalink($post_id) ?>" title="<?php echo get_the_title($post_id); ?>"> <?php echo get_the_post_thumbnail($post_id, 'custom_logo'); ?></a> 

You can see the Wordpress Codex for more exploitation.

Remember to set the images as a featured image on upload to be able to use it.

Codex Link

share|improve this answer
    
thank you for the advice! I think I already checked this out though, and, correct me if I am wrong, but this automatically crops the image. Ideally, I need to be able to choose where the image crops. That being said, I think Ill use this technique right now, and have a custom field for an alternate image to specify if the default cropping is bad. –  Zach L Dec 16 '11 at 20:13
    
@Zach L. Yes, it does not let you control where the image crops. I did not know that you needed the control. I have not tried it yet but there may be a solution at this link. Control Wordpress Crops –  John Bentwin Dec 16 '11 at 20:17
    
bummer... looks like this link only shows how to change how wordpress automatically crops the images, but does not give any hints as to how I might add this functionality to the backend –  Zach L Dec 16 '11 at 21:25
add comment

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.