Use Add_image_size in your functions.php
1 2 3 | function theme_sizes(){ add_image_size( 'custom-size', 800, 600); } |
in your code above use something like:
1 | wp_get_attachment_image( 42, 'custom-size' ); |
Add_image_size
adds a new option when you upload an image, which will then crop the image to the dimensions you need, so you would have thumbnail, medium, full size and your custom-size.
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.