Answer the question
In order to leave comments, you need to log in
Wordpress - get image size?
Friends, such a question, Google PageSpeed swears that the images are not set accordingly. sizes, tell me, how can I display the size of the picture in the template if it is different on each page. Those. you need to somehow get the size of the image in order to later display it in the img tag.
Answer the question
In order to leave comments, you need to log in
When using the image request functions, almost everyone has a $size parameter that you can pass in the size you want.
$img = wp_get_attachment_image( $attachment_id, $size, $icon, $attr );
<img>
srcset tag , where you can pass references to all available image sizes. Of these, the browser will be able to choose the most appropriate
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question