Answer the question
In order to leave comments, you need to log in
Why is the wp_get_attachment_image_url function not cropping the image?
Good afternoon.
You need to insert a picture with the specified dimensions, but for some reason a large picture is always inserted.
<img src="<?php echo wp_get_attachment_image_url( get_post_thumbnail_id(), [ 330, 228 ] ); ?>" alt="">
Answer the question
In order to leave comments, you need to log in
Read the documentation
https://wp-kama.ru/function/wp_get_attachment_image_url
The size of the image to get the URL for.
In this parameter, you can specify the basic WordPress sizes: thumbnail, medium, large or full.
Also, you can specify the size in an array, as two elements (width, height): array(32, 32). In this case, the most suitable size from the available ones will be selected, then the picture will be compressed / stretched to the specified sizes. Since version 2.5. this setting does not affect the size of media icons (icons for files), they are always shown in their original size.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question