I am making an attempt to output some pictures the appropriate manner, utilizing the wp_get_attachment_image
perform. This is how I do it:
echo wp_get_attachment_image( $image_id, 'image-size', '', [ 'class' => 'some-class' );
The thing is, it retrieves the image-size only (and outputs it as a class), if I use the first two arguments, $image_id
and 'image-size'
, like so:
<img width="260" height="350" src="[image-src-link]" class="attachment-image-size size-img-size" alt="" loading="lazy" />
Nevertheless, if I add a customized class because the fourth argument, as demonstrated within the first paragraph, it in some way overrides the picture dimension and makes use of solely the customized class, so that is what I get:
<img width="260" peak="350" src="[image-src-link]" class="some-class" alt="" loading="lazy" />
I completely do not get what I am doing flawed. I discovered this thread, the word within the accepted reply implies that that is some sort of bug, however the thread is nearly 8 years previous, and I feel the bug would’ve been resolved by now. Additionally, the WordPress Code Reference clearly states that the wp_get_attachment_image
can take 4 arguments and says completely nothing about picture dimension and customized class conflicts, so I am formally out of concepts.
May any person please steer me in the appropriate route?