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.

Okay, this is what I'm thinking about (and it's not a coding problem right now, but my fundamental thoughts): How to receive / input images in posts for special uses, let's say a customized portfolio post. The post content should not really contain the Work images. These images should be styled specifically in an own image area, separated from the common text content. What I used to do for quite a long time: I created a custom post meta box under the content with an upload button. Users could upload an image and the URL got inserted automatically there after pressing "Insert into post". Problem was, that the image should have the exact needed width. Now I changed this method and started to tell the User they would only have to upload the image, just like always, but don't insert it into post content. This made possible for me just to output the post gallery, and as I created an image size with the needed width, the size of the image wouldn't matter.

Now, most Users don't understand the new way and I also got the feeling that it is not as flexible as before (for example I could also add videos and rearrange videos and images in their order which doesn't work with my new method). I could use a thumbnail generation script or do it even myself, but this is not really a nice solution for me, too (performance, another caching, risk in use of scripts for example timthumb exploits...). I'm curious, do You have a solution or any thoughts for this?

Greatly appreciated, and please excuse my bad English ;) Best regards, .wired

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Wordpress already does the heavy lifting for you on this. All you need to do is use post thumbnails. If you don't see the featured image meta box on your pages/posts, place the following in your functions.php file.

add_theme_support('post-thumbnails');

From there you will need to define a new image size in your functions.php file.

add_image_size('special-image', 800, 600, true);

The fourth argument 'true' means Wordpress will do a hard crop and slice the image to this exact dimension. You can get rid of the custom field as this is a baked-in feature. To use this in your theme you will just use this tag:

the_post_thumbnail('special-image');
//or
get_the_post_thumbnail($post->ID, 'special-image);

For the images that you've already uploaded, I would recommend you install the Regenerate Thumbnails plugin. http://wordpress.org/extend/plugins/regenerate-thumbnails/. This will go back to all the images that have been uploaded and apply your specific size.

To learn more about post thumbnails: http://codex.wordpress.org/Post_Thumbnails

Hope this helps!

share|improve this answer
    
Hey Brian, thanks for the help but my issue goes far beyond this. I know this function of WordPress really well and use it often. And it's not about only one Featured Image. It's about many images, attached to a post and handled in the output, like the featured image. I mean, the user uploads many images and I want to crop for him. I could do this with the common WordPress default uploader and read out the gallery attached to the post, I also could create new meta fields, getting their values with get_post_meta() easily, too. But then the user will have to upload an image already cropped :( –  maximski Sep 15 '11 at 13:41
    
Enter the awesome plugin Multiple Post Thumbnails. wordpress.org/extend/plugins/multiple-post-thumbnails I've used this many times for this type of scenario! –  Brian Fegter Sep 15 '11 at 13:43

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.