Answer the question
In order to leave comments, you need to log in
How to maintain image aspect ratio in WordPress?
Images from previews are displayed strongly distorted if the preview field and the image itself do not match in proportion.
Screenshot : habrastorage.org/files/954/e4a/ac6/954e4aac6ec94d3...
Here inform.kharkov.ua
It is displayed
like this:
echo '<div class="spec"><a class="spec-img" href="'.get_permalink().'">'.get_the_post_thumbnail($page->ID, 'thumbnail').'</a><div class="spec-title"><a href="'.get_permalink().'">'.get_the_title().'</a></div></div><div class="its">';
Answer the question
In order to leave comments, you need to log in
No need to connect all sorts of BFI_thumb, TinThumb and other heresy, I beg you! WP has native tools!
Get image url:
<?php wp_get_attachment_image_src( $attachment_id, $size, $icon ); ?>
[0] => url
[1] => width
[2] => height
[3] => boolean: true if $url is a resized image, false if it is the original.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question