AI Verified
Disable and Delete Image Sizes Generated by WordPress
This WordPress code snippet optimizes image handling by disabling automatic generation of various image sizes during uploads and removing existing generated sizes, thereby enhancing site performance and reducing unnecessary storage usage.
PHP
Voted: 0 by 0 user(s)
I/ Using Theme's functions.php File 1. Log in to your WordPress admin. Go to "Appearance" -> "Theme Editor." 2. Find and select the functions.php file. 3. Scroll to the bottom and paste the code. 4. Click "Update File" to save. II/ Using a code snippet plugin 1. Install and activate your preferred plugin. 2. Find the plugin in the WordPress dashboard. 3. Create a new snippet. Paste the code and save. 4. Activate the snippet to enable the functionality. Remember to test changes on a staging site or backup before applying on a live site.
Scroll down to see more snippets from this codevault.
The author has indicated that this snippet is compatable up to wordpress version: 6.1
Our AI bot has checked this snippet is compatable up to wordpress version: 6.1
Free & Pro
Download this snippet by clicking the download button, then head over to the Code Snippet Plugin settings in your wordpress admin dashboard, select the import menu then upload this file to import into your wordpress site.
Pro Only (Coming Soon)
You will be able to click a button and sync this snippet to your wordpress site automatically and from your dashboard manage all code snippets across all your wordpress sites that have the Code Snippets Pro plugin installed.
Last modified:
02/12/2023
This snippet has the following status:
AI Verified
This snippet has been tested by our AI bot, see any comments below.
AI Bot Comments:
Potential vulnerability found : File Inclusion / Path Traversal
Found on line : -1
Code : file(= $upload_dir['basedir'] . '/' . $path['dirname'] . '/' . $size_data['file'])
Vulnerable line : 20
Code : $path = pathinfo($meta['file']));
Potential vulnerability found : File Inclusion / Path Traversal
Found on line : 37
Code : file($intermediate_file)
Vulnerable line : 30
Code : $intermediate_file = $upload_dir['basedir'] . '/' . $path['dirname'] . '/' . $size_data['file']);
Found 2 vulnerabilities
0
Please see some snippets below related to this snippet..
General
AI Verified
General
AI Verified
Added: 9 months ago
Last Updated: 9 months ago
<p>Make sure video embeds like YouTube size responsively</p>
General
AI Verified
These are some popular snippets from this users codevault..
General
AI Verified
Added: 7 months ago
Last Updated: 7 months ago
Delete from the database the images that WP automatically generated from uploaded images
General
AI Verified
Added: 7 months ago
Last Updated: 7 months ago
This WordPress code snippet optimizes image handling by disabling automatic generation of various image sizes during uploads and removing existing generated sizes, thereby enhancing site performance a...
Category
Snippet Status