0

In WordPress, media items (images) have attributes associated with them that control how they get rendered as HTML. WP version 5.5 added the loading attribute and version 6.1 added the decoding attribute.

How do I actually change the values of these attributes for a specific image?

Chris Sears
  • 6,502
  • 5
  • 32
  • 35
  • How are you outputting this image? Or do you want this to occur globally for one specific image? `wp_img_tag_add_decoding_attr` https://developer.wordpress.org/reference/functions/wp_img_tag_add_decoding_attr/ or you can probably use this https://developer.wordpress.org/reference/hooks/wp_get_attachment_image_attributes/ – disinfor Jul 12 '23 at 21:21
  • I'm looking to change the attributes of one specific image, not globally. And I appreciate the pointers to the API docs, but I was hoping there was something in the Admin UI that allowed non-technical users to update the media attributes. It seems odd that WP would implement this functionality but not expose it in the UI anywhere. – Chris Sears Jul 13 '23 at 06:17
  • You could technically use ACF or custom meta field to add fields to the UI for non-tech users, but then use the docs referenced to query that data for image output. – disinfor Jul 13 '23 at 12:46

0 Answers0