How to delete resized (cropped) image uploads and prevent future resizing?

I want to delete all the resized images while leaving the original image. I have more than 20 GB of unused data taking up room on the server. For example: first-image-name.jpg first-image-name-72x72.jpg first-image-name-150x150.jpg first-image-name-250x250.jpg first-image-name-300x300.jpg first-image-name-400x400.jpg first-image-name-1024x1024.jpg second-image-name.jpg second-image-name-72x72.jpg second-image-name-150x150.jpg second-image-name-250x250.jpg second-image-name-300x300.jpg second-image-name-400x400.jpg second-image-name-1024x1024.jpg Is there a way to delete all the resized images and disable creating such ones in the future?
Category: Web

There has been an error cropping your image

I've searched quite a bit and every single article seems to suggest the same thing, which I've tried to no avail. I've already tried installing php7.4-gd. it did not fix the issue. I tried adding this snippet to my functions.php file: add_filter('wp_image_editors', 'wpse303391_change_graphic_editor'); function wpse303391_change_graphic_editor($array) { return array('WP_Image_Editor_GD', 'WP_Image_Editor_Imagick'); } Neither of these have fixed my issue. I'm running XAMPP on debian. I imagine it has something to do with permissions because it's linux and 99% of all linux issues …
Category: Web

Cropping, Re-sizing and Saving images from one folder to another folder in wordpress

I'm adding an upgrade for the WordPress plugin which I have developed ages ago. This plugin is just a product catalog, so just show products and their images. Products can have more than one images. I was re-sizing images in the older version of the plugin by CSS, assigning them width and height. Which was working but images look stretched but users were happy. Now I have added a new feature in the plugin which is to crop and re-size …
Category: Web

Plugin to select the custom image crop area

I've defined the custom thumbnail sizes and set it up in a mu-plugins script. <?php function penge_features() { add_theme_support('post-thumbnails'); add_image_size('Homepage Carousel', 1210, 540, true); // new add_image_size('Article Hero', 800, 267, true); // new add_image_size('Landing Page Hero', 1210, 300, true); // new add_image_size('1/3 Tile', 390, 350, true); // new add_image_size('1/2 Tile Desktop', 290, 350, array('center', 'center' )); // new - Home page, image required add_image_size('1/2 Tile Tablet', 188, 350, array('center', 'center' )); // new - Home page, on some tablets add_image_size('tyle', …
Category: Web

How do I get a smaller size of an avatar image

I have a function that creates a bio-line at the top of every post. One part gets the avatar of that user, that he uploaded in WordPress (I use a plugin so people don't need to use Gravatar for this). function mm_author_byline() { if (is_single() AND (get_post_type() == 'post' OR get_post_type() == 'theme_product_review')) { ?> <div class="mm-byline-image"> <?= get_avatar(get_the_author_meta('ID')) ?> </div> <?php } } The problem now is, that this image is neither cropped, nor is it sized down. It …
Category: Web

Apply manual image cropping not to thumbnail but medium_large size

When cropping an image in wordpress you can apply the changes to all image sizes at once, the thumbnail (150 x 150) or all sizes except thumbnail. I would like to be able to select other image sizes as well, such as medium or medium_large. Does anyone have an idea how to apply image cropping "only" to a specific image size except thumbnail?
Category: Web

Removing extra large generated images disables all crops

function filter_image_sizes( $sizes) { unset( $sizes['1536x1536']); // disable 2x medium-large size unset( $sizes['2048x2048']); // disable 2x large size return $sizes; } add_filter('intermediate_image_sizes_advanced', 'filter_image_sizes'); I check the uploads folder and only the original image is being added now. I check the docs and I don't think I see it removing all the crops because of it. Am I doing something wrong? When removing those sizes, do I need to add back the default sizes?
Category: Web

using media uploader to select image of specific size, enforce cropper

I've followed this article to use Media Uploader in my code. When I click the Browse button on my form, the media uploader opens and after selecting the image, I get the URL of that image added in my form field. No issues so far. But I want to enforce the image to be of a specific size. If the size is different, user must crop it to match the required size (or aspect ratio) before he can select the …
Category: Web

Local WordPress installation doesn't crop images

When I try to crop an image in the WordPress backend area of my custom theme, I get the message "There has been an error cropping your image". I have it set up on a local machine using XAMPP. When I set up the exact same theme on a server, it works perfectly fine. I checked quite some questions that seemed to be similar to my problem, but nothing worked so far. I disabled all plugins. I checked the php.ini …
Category: Web

How to crop image in WordPress with aspect ratio for any size of image

I am using following function for cropping image in wordpress and I want to crop image in 1:1 aspect ratio. When I upload large image compared to specified size in function it works well but when I upload smaller image compare to specified in function size it does not produce 1:1 but it takes height or width that fits best and produce image in other aspect ratio. add_image_size('member-photo', 200, 200, true); https://developer.wordpress.org/reference/functions/add_image_size/ But I need 1:1 image in ratio so …
Category: Web

variable crop option with add_image_size()

In my child Theme I have set my custom image with add_image_size( 'big', 1500, 1000 ) I left out the crop parameter, but it is [false by default][1] anyway. I want to make this a variable option. I have just written a plugin that displays all the registered image sizes (including WP's thumbnail, medium and large sizes) plus my custom size. With checkboxes I do update_option($_size."_crop", true) for WP's image sizes and global $_wp_additional_image_sizes; $_wp_additional_image_sizes[$_size]['crop'] = true for my custom …
Category: Web

Can't locate custom image sizes defined by child theme

I'm developing a child theme (mms-child) based on a simple parent (mms – also my dev). I am quite used to the usual way of defining custom image sizes within functions.php as follows: add_theme_support( 'post-thumbnails' ); add_image_size( 'Size name', 2000, 9999 ); I have removed all instances of this in the child theme's functions file, and checked to make sure there is nothing like this in the parent theme either. So – I am expecting nothing in my list of …
Category: Web

Disable Responsive Image Sizes crop

I think my question might similar to others.Here is my problem, I want to remove generating wordpress responsive images because I have done image responsive solution with my way. So, I don't wanna save any auto generated images from wordpress in my server. When I google it, most show how to remove from tag at frontend.
Category: Web

Show image crop window on image upload

I'm trying to add image from front end and crop it after upload. Used setState( 'cropper' ); to enable image crop window. It open the image upload window. Upload an image. But, Not open Image Crop window. Reference from https://core.trac.wordpress.org/browser/tags/4.6/src/wp-admin/js/customize-controls.js#L2449 Add Shortcode: [frontend-image-upload] function frontend_image_upload() { wp_enqueue_media(); wp_enqueue_script( 'media-grid' ); wp_enqueue_script( 'media' ); wp_enqueue_script( 'frontend-image-upload', plugins_url( '../assets/js/frontend-image-upload.js', __FILE__ ), array( 'jquery', 'media-upload' ), NULL, true); } add_action( 'wp_enqueue_scripts', 'frontend_image_upload' ); add_shortcode('frontend-image-upload', function() { ob_start(); ?> <button class="frontend-image-upload">File Open</button> <?php return …
Category: Web

Why WordPress automatic cropping all my images?

Am new to WordPress, when I upload any image, WordPress automatic crops into its own sizes which I have not mention in the media section (Settings » Media). Settings which I saved in media is: And when I check in the directory it crop automatically into these sizes: How this thing is happening?
Category: Web

Cropping an image before inserting into a post

I've got a frontend post form, and I've been using this PHP code to allow uploading an image and to insert it into a post. // image upload and attatching to post if ( ! empty( $_FILES ) && ! empty( $_FILES['upload-image']['name'] ) ) { // upload image to server $upload = wp_upload_bits( $_FILES['upload-image']['name'], null, file_get_contents( $_FILES['upload-image']['tmp_name'] ) ); // insert new image to the just created post ================================ $wp_filetype = wp_check_filetype( basename( $upload['file'] ), null ); $wp_upload_dir = wp_upload_dir(); …
Category: Web

Custom image size / thumbnail - Crop to aspect ratio even when source image is smaller than set dimensions

Normally when you set a custom image size using hard crop - e.g. add_image_size( 'custom-size', 400, 400, true ); - you get the following results: #1 Uploaded image: 600x500 > Thumbnail: 400x400. #2 Uploaded image: 500x300 > Thumbnail: 400x300. #3 Uploaded image: 300x200 > Thumbnail: 300x200. However what I'd like to do is when the uploaded image is smaller than the set width, or height, or both, of the custom image size, e.g. examples #2 & #3 above - instead …
Category: Web

Stop WordPress from cropping images using url parameters

I've specified some custom image sizes each with a non-default crop position (e.g. top-center). However, when I use wp_get_attachment_image and specify size to be one that I defined, I get a correctly sized image with an incorrect crop position. It turns out that the image URI is of the form https://i1.wp.com/example.com/wp-content/uploads/2017/11/myimage.jpg?resize=293%2C160, even though I definitely have the proper https://example.com/wp-content/uploads/2017/11/myimage-293x160.jpg image with correct crop position. Interestingly, though, wp_get_attachment_metadata returns the correct, static URI for the given image size. Why is WordPress …
Category: Web

Why does the Hard Crop option Scale?

I have a number of custom image sizes. I noticed earlier, when I was publishing a new post, that the post image was cropped AND scaled. It is exactly the right dimensions.. but it isn't the portion of the image it should be. This is the code in functions.php, for this particular image size. add_image_size( 'post', 800, 350, array( 'left', 'top' ) ); Take a look at the original size: http://cppcooper.com/wp-content/uploads/2016/03/ThreadExtraction.png Now look at the "hard cropped" version: http://cppcooper.com/wp-content/uploads/2016/03/ThreadExtraction-800x350.png It …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.