Replacing image attributes (data-src) also applies to backend

Solution is simple, check that is_admin() returns false before doing any modifications to the content, or hook on admin_init to add you hooks. I don’t think that the_content is used in the context of admin, but thumbnail generation might be used. Another thing to keep in your mind is that those hooks might be triggered … Read more

How to Display Featured Image Title and ALT Attribute

Maybe following function is what you are looking for. The important part you are looking for in the code is the line which holds the pathinfo, which is php and not WordPress specific. There are probably several other options but as nobody responded till now I think that this function will help you out till … Read more

Display one random image, but only if landscape

ok, following the comments: //from https://stackoverflow.com/questions/37537577/wordpress-query-by-attachment-meta-image-size add_filter(‘wp_generate_attachment_metadata’, ‘add_metac’, 10, 2); function add_metac($meta, $id){ update_post_meta($id, ‘height’, (int) $meta[‘height’]); update_post_meta($id, ‘width’, (int) $meta[‘width’]); update_post_meta($id, ‘ratio’, round ($meta[‘width’] / $meta[‘height’] , 2 )); return $meta; } at this point you will have, for the newly uploaded images, in the postmeta table all the information and a ratio >1 … Read more

Force all images to full size in page template

This code works, although I suspect that it could be more efficient – or replaced by a better filter. I modified this code from the answer to this question, which was the best choice out of all the googles I spent hours trying out.enter link description here You will need to change the ‘full’ to … Read more