Description
Re-renders Image Choice field markup to use the full-size image (with original dimensions, srcset, and sizes) when the field has the CSS class original-aspect-ratio, and overrides the default fixed aspect ratio so each choice displays at its natural ratio.
Usage Notes
Add the custom CSS class original-aspect-ratio to any Image Choice field on which the original aspect ratio should be preserved. Both the PHP and CSS blocks are required. PHP requires WP_HTML_Processor (WordPress 6.4+). Larger source images may increase page weight — confirm performance is acceptable for the chosen images.
Code
Please log in to view this code snippet.
Please log in to view this code snippet.