Rename media files generated during upload

Using my own code from here, i updated the logic to add the name of the image size instead of the suffix, try adding this to your functions.php file: add_filter(“wp_image_editors”, “my_wp_image_editors”); function my_wp_image_editors($editors) { array_unshift($editors, “WP_Image_Editor_Custom”); return $editors; } // Include the existing classes first in order to extend them. require_once ABSPATH . WPINC . … Read more

Local WordPress installation doesn’t crop images

For the record since I ended up here when experiencing the same issue on my localhost: In php.ini, Uncomment the line with: extension=php_gd2.dll Restart apache / all services This sorted it out for me (I may have switched a few other services on while I was there, but I believe this is what fixed it!)

How to add image id class?

Shamelessly copied from here: https://letswp.io/add-attachment-id-to-the-class-of-wordpress-images/ add_filter( ‘wp_get_attachment_image_attributes’, ‘add_image_id_class’, 10, 2 ); function add_image_id_class( $attr, $attachment ) { $class_attr = isset( $attr[‘class’] ) ? $attr[‘class’] : ”; $has_class = preg_match( ‘/wpimage\_[0-9]+/’, $class_attr, $matches ); if ( !$has_class ) { $class_attr .= sprintf( ‘ wpimage_%d’, $attachment->ID ); $attr[‘class’] = ltrim( $class_attr ); } return $attr; } This … Read more

Restrict Image Uploads to a Certain File Type

First off, PNGs do not necessarily slow your site down anymore than a JPG. It all depends on how the image is saved or optimized and the file size. Anyway. You have a couple options. Since this site is about coding and we don’t support 3rd party plugins I will give you this first. You … Read more