Add new image size to media uploader so users can insert into post?
Just found a new plugin which seems to do exactly what I described above: http://wordpress.org/extend/plugins/additional-image-sizes-zui/ Hope this helps someone!
Just found a new plugin which seems to do exactly what I described above: http://wordpress.org/extend/plugins/additional-image-sizes-zui/ Hope this helps someone!
You can use the wp_generate_attachment_metadata filter: function wpse_183835_to_jpeg( $meta, $post_id ) { $sizes_to_convert = array( ‘thumbnail’, ); $path = dirname( get_attached_file( $post_id ) ); foreach ( $sizes_to_convert as $size ) { if ( ! empty( $meta[‘sizes’][ $size ] ) ) { $data = $meta[‘sizes’][ $size ]; if ( $data[‘mime-type’] === ‘image/png’ && is_file( $file = … Read more
The featured image attachment id is stored in the post_meta table, with the meta_key _thumbnail_id. Use that post id to find the post meta with meta_key _wp_attachment_metadata. The value of that is a serialized array with keys thumb, file, width, height, sizes (an array), and image_meta (an array). The file value is relative to the … Read more
Unfortunately there is no legal way to control it. But there is a dirty way to do it… If you select this route, then you will need to : clone the standard gallery_shortcode function add a default value for $attr[‘link’] option hook your cloned function into post_gallery filter The final result will look like this: … Read more
You can try the following to clear the image attachment’s title when it’s inserted but not updated: /** * Empty the image attachment’s title only when inserted not updated */ add_filter( ‘wp_insert_attachment_data’, function( $data, $postarr ) { if( empty( $postarr[‘ID’] ) && isset( $postarr[‘post_mime_type’] ) && wp_match_mime_types( ‘image’, $postarr[‘post_mime_type’] ) ) $data[‘post_title’] = ”; return … Read more
It sounds like you need to change the URLs for the old images. The easiest & quickest way of doing that is to do a find and replace on the MySQL database. You can use PHPMyAdmin (usually provided by your web host) or other MySQL editing software such as Sequel Pro to make changes to … Read more
Concerning documentation there is this blog post on the Make Blog: Responsive Images in WordPress 4.4 To increase the 1600px limit mentioned in the comments try this: add_filter(‘max_srcset_image_width’, function($max_srcset_image_width, $size_array){ return 2000; }, 10, 2); Finally as already mentioned you should fix your calls to add_image_size add_image_size(‘news-large’, 1024, false); needs to be add_image_size(‘news-large’, 1024, 0, … Read more
The Approach I think the best approach is to create an image size “on the fly”, just before the images is resized. You can do that using ‘intermediate_image_sizes_advanced’ filter hook. That allows you to edit the size to be generated, but being aware of the current image size, that is stored in the array $metadata … Read more
I recently had to do this via a nightly cron script for a social media stream. $parent_id is the ID of the post you want to attach the image to. function uploadRemoteImageAndAttach($image_url, $parent_id){ $image = $image_url; $get = wp_remote_get( $image ); $type = wp_remote_retrieve_header( $get, ‘content-type’ ); if (!$type) return false; $mirror = wp_upload_bits( basename( … Read more
I found the culprit! WordPress 5.3 introduced additional image sizes which can be found via /wp-includes/media.php. Updating my function, like so, removed the extra sizes: function remove_default_image_sizes( $sizes) { unset( $sizes[‘large’]); // Added to remove 1024 unset( $sizes[‘thumbnail’]); unset( $sizes[‘medium’]); unset( $sizes[‘medium_large’]); unset( $sizes[‘1536×1536’]); unset( $sizes[‘2048×2048’]); return $sizes; } add_filter(‘intermediate_image_sizes_advanced’, ‘remove_default_image_sizes’);