i’m developing a portfolio theme on WordPress 3.2.1, so i created a new post_type called ‘portfolio’. My aim is to show, on the front-end, a grid composed by the jobs i realized during last years.
This gris will be filled by portfolio post_type thumbnail (featured image), when any user click on them, system shows (through fancybox) a popup with the large image in it.
So, the HTML code I expect is:
<a title="the title" href="http://img.mywordpresstips.com/post-thumbnails/screenshot-648x1024.png" rel="something"> <img class="attachment-portfolio-thumb wp-post-image" width="214" height="187" title="screenshot" alt="screenshot" src="http://img.mywordpresstips.com/post-thumbnails/screenshot-e1314198521926.png"> </a>
The idea is to: upload image from portfolio section (using the button add image), then save and close this section. Then, I move to media library, I open the image to crop it. Next step is to save all media, back to the portfolio section, open the post again and set the cropped image as the featured image.
What happens is that “crop” does not work. I’ve to crop the image twice to have a result, but it does not affect the image all the times.
Do you guys have any experience on that?
Apart from the php code i use to show the thumbnail, i can’t stand by wordpress and crop don’t do what i need (please note that I want to crop the image, I do not need the programmatically crop that wordpress offers).
You don’t need to do manual cropping; just create a custom image size, and WordPress will perform the cropping on image upload.
e.g. in functions.php:
add_image_size( 'portfolio-thumbnail', 214, 187, true );
Then in your portfolio template, inside the Loop:
the_post_thumbnail( 'portfolio-thumbnail' );
(I assume you know how to handle the rest of the output, such as creating the grid layout, and linking each thumbnail image, etc.)
Note: you’ll have to regenerate thumbnails for any already-uploaded images.