short-pixel-optimizer / shortpixel-image-optimiser

ShortPixel Image Optimizer WordPress Plugin
15 stars 7 forks source link

=== ShortPixel Image Optimizer - Optimize Images, Convert WebP & AVIF === Contributors: ShortPixel Tags: convert webp, optimize images, image optimization, resize, compressor Requires at least: 4.8.0 Tested up to: 6.6 Requires PHP: 5.6 Stable tag: 5.6.4 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html

Optimize images & PDFs smartly. Create and compress next-gen WebP and AVIF formats. Smart crop and resize.

== Description ==

Optimize images and create WebP/AVIF versions with an easy-to-use, comprehensive, lightweight, stable and frequently updated freemium image compression plugin supported by the friendly team that created it.

Increase your website's SEO ranking, number of visitors, and ultimately your sales by optimising any image or PDF document on your website. ShortPixel is an easy to use, lightweight, install-and-forget-about-it image optimization plugin that can compress all your past images and PDF documents with a single click. New images are automatically resized/rescaled and optimized on the fly, in the background. It's also compatible with any gallery, slider or eCommerce plugin.

Ready for a quick DEMO? Test our plugin here and here. Or you can create a staging copy of your site using WP Staging and test it there.

Short Pixel uses minimal resources and works well with any shared, cloud, VPS or dedicated web hosting. It can optimize any image you have on your website even the images that aren't listed in Media Library like those in galleries like NextGEN, Modula or added directly via FTP!

Both lossy and lossless image compression are available for the most common image types (JPG, PNG, GIF, WebP, and AVIF) plus PDF files. We also offer glossy JPEG compression which is a very high-quality lossy optimization algorithm. Specially designed for photographers! Optimized images mean better user experience, better PageSpeed Insights or GTmetrix results, better Google PageRank, and more visitors.

Make an instant image compression test of your site or compress some images to test our optimization algorithms.

New Plan: ShortPixel Unlimited

This is the perfect monthly plan for single website owners. It allows you to optimize an unlimited number of images with ShortPixel Image Optimizer on your website. Read more details on our dedicated page.

New! HEIC file support With ShortPixel you can now add images in Apple format (HEIC) directly from your iPhone. They will be automatically converted to JPG and then optimized according to your settings. Easy! Read more.

Smart Cropping

With this new feature, all thumbnails used on your website are not only optimized, but also regenerated to fully display the subject of the image. All thumbnails fully display the subject and look consistent as well. The new thumbnails look sharper (and can be slightly bigger) than the ones created by WordPress. Ideal for e-commerce and other websites where the images are paramount to selling the products or to support the content. See an example.

Why is ShortPixel the best choice when it comes to image optimization or PDF compression?

How much does it cost? ShortPixel comes with 100 free credits/month and additional credits can be bought for as little as $4.99 for 5,000 image credits. Check out our prices.

Testimonials: ★★★★★ A Super Plugin works very well 62% reduction overall. robertvarns ★★★★★ The secret sauce for a WordPress website. mark1mark ★★★★★ A must have plugin, great support! ElColo13 ★★★★★ Excellent Plugin! Even Better Customer Service! scaliendo ★★★★★ Great image compression, solid plugin, equally great support. matters1959 more testimonials

[youtube https://www.youtube.com/watch?v=FVPWeNsJWss]

Help us spread the word by recommending ShortPixel to your friends and collect 100 lifetime monthly additional image credits for each referred active user. Make money by promoting a great plugin with our 30% commission affiliate program.

Other plugins by ShortPixel

Get in touch!

== Installation ==

Let's get the ShortPixel plugin running on your WordPress website:

  1. Sign up using your email at https://shortpixel.com/wp-apikey.
  2. You will receive your personal API key in a confirmation email, to the address you provided.
  3. Upload the ShortPixel plugin to the /wp-content/plugins/ directory
  4. Use your unique API key to activate the ShortPixel plugin in the 'Plugins' menu in WordPress.
  5. Uploaded images can be automatically optimized in the Media Library.
  6. Done!

== Frequently Asked Questions ==

= How does ShortPixel compare to other image optimisation plugins (e.g Smush, Imagify, TinyPNG, Kraken, EWWW, Optimole)? = ShortPixel consistently has better compression rates along with more features, backup support and has very affordable one-time or monthly plans. Here are a couple of independent reviews: AuthorityHacker - "ShortPixel is our tool of choice, simply because it’s pretty much automated – we just let it do its thing." (read full review) WP Modula - "One of the reasons I’m personally a huge fan of ShortPixel is the built-in support for next-gen image formats like WebP." (read full review)

= Can I use the same API Key on multiple web sites? = Yes, you can. As long as you have available credits, you can use a single API Key on as many websites as you wish!

= What plan is better for me? What do you recommend? = Everyone has different needs, but generally, we recommend getting a One-Time plan to optimize your whole Media Library and then get a Monthly plan to optimize your future uploads. To learn more, have a look at this comparison

= I don't know how many thumbnails do I have, what plan should I take? To know how many thumbnails you have, just install the plugin and go to Media > Bulk ShortPixel. The plugin will tell you how many thumbnails you've got. Based on this, have a look at our plans

= Can I upgrade/downgrade easily my plan? = Of course. You can upgrade or downgrade your plans in a couple of clicks from your account on shortpixel.com.

= Can I test/use the plugin for free? = Yes, you can. We offer 100 free image optimization credits each month. Exceeding the monthly free quota will pause the optimization process till the quota is reset or extended by buying one of our plans.

= Can I optimize images that aren't in Media Library? = Absolutely. You can actually optimize any image you have on your site regardless of its place. You just need to add - in the Advanced section of the ShortPixel Settings - the folders where the images you want to optimize are located and ShortPixel will work its magic and do the rest.

= Can I optimize images that are both past and new? = Sure! You can optimize all your past/current images and photos using our "Bulk ShortPixel" page in your Media with a single click.

= A credit = an optimized image? = Yes, that is correct. But please note that usually, an image in Media Library has 5 or more associated thumbs. Each optimized thumbnail requires a credit. In the rare cases when ShortPixel does not optimise the image (lossy) with at least 5%, the credit will not be consumed, though.

= Can I restore my images? What happens with the originals? = If you choose the "Image backup" option in Settings/ShortPixel then the original version of any optimized image or PDF will be saved in the backup folder. The original image is needed if you want to restore an image or if you want to convert an image from lossy/glossy to lossless or vice-versa.

= What types of formats can be optimized? = ShortPixel optimises JPEG (JPG, JPEG, JPEG 2000, JPEG XR), PNG, GIF (animated and still), and PDF type of files.

= Do you have one-time plans? = Yes we do. The credits that come with our one-time plans never expire. Yummy! :-)

= What happens to my existing images? = Your existing images are replaced with the optimized ones. If you choose the backup option then the originals will be saved in a separate folder so you can restore them should you ever need/want to do that.

= How does the plugin work? = Our lightweight plugin sends the original images to our Image Optimization Cloud where they are compressed. ShortPixel then downloads the optimized images and the unoptimized originals are replaced with the optimised versions.

= Do you optimize images in the cloud? = Yes, all the images processed by ShortPixel are optimized in the Cloud. This takes the load off of your server and allows us to produce the best results.

= What payment methods are accepted? = We accept payments via card (Mastercard, Visa, Maestro, American Express, Discover, Diners Club, JCB, UnionPay), PayPal, and Apple Pay.

= How do I activate the API key on a multisite? = You have to activate the plugin in the network admin and then activate it manually on each individual site in the multisite. Once you have done that, the Settings menu appears and you can add the API key for each individual site. As an alternative, you can edit wp-config.php and add this line:

define('SHORTPIXEL_API_KEY', 'APIKEY'); where APIKEY is the API Key received upon sign up. If configured that way, the API key will be used for all the sites of the multisite but will only be visible on the main site’s Settings page, being hidden for the rest of the sites.

= I am not the only one working on the WordPress Dashboard. How can I hide my API key? = There is a simple way to hide the API key, all you need to do is to add these two lines in your wp-config.php:

define('SHORTPIXEL_API_KEY', '<<your api key here>>'); define('SHORTPIXEL_HIDE_API_KEY', true);

= How much is a credit? = A credit is used each time ShortPixel optimizes an image or thumbnail by at least 5%. If we're not able to optimize an image or thumbnail by at least 5% then no credit will be used :-) Please also note that usually images in your Media Library have 3-5 thumbs associated and a credit will be used for each featured image or associated thumbnail that is optimized.

= Why shall I use a WordPress plugin and not an offline tool? = Because ShortPixel algorithms were perfected while optimizing over 3.5 billion real-life images. ShortPixel not only offers the best compression for JPEG, PNG, GIF, and PDF files but it also saves you a lot of time. You just install it on your site and then ShortPixel will take care that all the images on your site are immediately optimized after upload.

= Does optimizing images affect my ALT tags? = No, ShortPixel only optimizes images, it won't touch anything else like your HTML/CSS.

= If I stop using ShortPixel will my images remain optimized? = Absolutely! Once optimized, the images will remain optimized unless you explicitly choose to restore them. But why would you do that? :-)

= Do I have to pay monthly or one time? = We have both options available. One-time credits never expire and are a bit more expensive. Check out our prices here

= When can I cancel a monthly plan? = Whenever you want. The credits you still have available for the current billing period will still be available until the end of the billing period. At the end of it, you won't be billed again and the plan will be reset to the free plan.

= When do credits expire? = Monthly credits expire after 30 days while one-time credits never expire.

= Do you have an API? = Yes, we have several APIs and tools. You can learn more about it here: https://shortpixel.com/api-tools

= Can I use the ShortPixel WP plugin on a localhost installation? = Unfortunately not :-( But you can use either our command line tool or our web tool https://shortpixel.com/web-tool-docs https://shortpixel.com/cli-docs

= How does resizing work? = If you choose the option to resize images on your site, then the featured image can be resized to a predefined size while keeping its aspect and proportions intact. The associated thumbs won't be resized. Using this option you can safely upload original images safely without needing to apply any pre-processing to make them smaller.

= Will ShortPixel work if my website is using CloudFare? = Absolutely! Sometimes you'll need to make sure you whitelist some IPs, just contact us and we'll assist you with that.

= Where do I report security bugs found in this plugin? = Please report security bugs found in the source code of the ShortPixel Image Optimizer plugin through the Patchstack Vulnerability Disclosure Program. The Patchstack team will assist you with verification, CVE assignment, and notify the developers of this plugin.

= I’m stuck. What do I do? =

The ShortPixel team is here to help. Contact us!

== Actions and Filters for Developers ==

The ShortPixel Image Optimiser plugin calls the following actions and filters:

do_action( 'shortpixel_image_optimised', $post_id ); upon successful optimization;

do_action("shortpixel_before_restore_image", $post_id); before restoring an image from backup;

do_action("shortpixel_after_restore_image", $post_id); after succesful restore;

For version 4.22.10 and earlier:

apply_filters("shortpixel_backup_folder", $backup_folder, $main_file_path, $sizes); just before returning the ShortPixel backup folder, usually /wp-content/uploads/ShortpixelBackups. The $sizes are the sizes array from metadata;

For version 5.0.0 and later:

$directory = apply_filters("shortpixel/file/backup_folder", $directory, $file); just before returning the ShortPixel backup folder, usually /wp-content/uploads/ShortpixelBackups).

apply_filters('shortpixel_image_exists', file_exists($path), $path, $post_id); post ID is not always set, only if it's an image from Media Library;

apply_filters('shortpixel_image_urls', $URLs, $post_id); filters the URLs that will be sent to optimisation, $URLs is a plain array;

The filter below is deprecated starting with version 5.0.0!

apply_filters('shortpixel/db/chunk_size', $chunk); the $chunk is the value ShortPixel chooses to use as the number of selected records in one query (based on total table size), some hosts work better with a different value;

For version 4.22.10 and earlier:

apply_filters('shortpixel/backup/paths', $PATHs, $mainPath); filters the array of paths of the images sent for backup and can be used to exclude certain paths/images/thumbs from being backed up, based on the image path. $mainPath is the path of the main image, while $PATHs is an array with all files to be backed up (including thumbnails);

For version 5.0.0 and later:

apply_filters('shortpixel/image/skip_backup', false, $this->getFullPath(), $this->is_main_file) filters the images that are skipped or not from the backup. Return true for the type of images to be skipped in the backup. If you check if is_main_file is true and return false (do not skip backup), while while otherwise returning true, the backup will be kept only for the main image. We suggest using it in conjuction with this action that fires right after the restore from backup is done:

do_action('shortpixel/image/after_restore', $this, $this->id, $cleanRestore); This action can be used to cleanup the meta data from the database, regenerate thumbnails after restoring the main file, writing the updated meta data, etc.

apply_filters('shortpixel/settings/image_sizes', $sizes); filters the array ($sizes) of image sizes that can be excluded from processing (displayed in the plugin Advanced settings);

apply_filters('shortpixel/image/imageparamlist', $result, $this->id, $this); filters the list of parameters sent to the API so that resizing can be performed more granularly;

apply_filters('shortpixel/api/request', $requestParameters, $item_id); filters the parameters sent to the optimization API (through $requestParameters), described in detail here: ShortPixel Reducer API; $item_id contains the ID of the Media Library item, or the ID of the Custom Media item (when used). In short, this filter can be used to alter any parameters sent to the API, depending on the needs. For example, you can set different resize parameters for different post types, different compression levels, remove EXIF or not, covert WebP/AVIF, and basically any other parameter that is sent to the API for a specific image (together with all its thumbnails).

This filter enables the background ShortPixel processing in additional pages (see here the original list). Here's an example of this filter that enables the processing on the Comments screen (to be placed in your functions.php file):

add_filter('shortpixel/init/optimize_on_screens', function ($screens) { $screens[] = 'edit-comments'; return $screens; }); The edit-comments is the ID of the screen where you want to enable the processing.

If you want to add multiple pages, here's what the snippet looks like:

add_filter('shortpixel/init/optimize_on_screens', function ($screens) { $screens = array('edit-comments', 'plugins', 'another-custom-post-type-page'); return $screens; });

add_filter('shortpixel/image/filecheck', function () { return true; }); This filter forces a file check for WebP/AVIF in case they were manually removed from disk.

If you want to disable the automatic cache flush that is triggered after image optimization, you can use this filter:

add_filter( 'shortpixel/external/flush_cache', function() { return false; } );

In order to define custom thumbnails to be picked up by the optimization you have two options, both comma separated defines:

define('SHORTPIXEL_CUSTOM_THUMB_SUFFIXES', '_tl,_tr'); will handle custom thumbnails like image-100x100_tl.jpg;

define('SHORTPIXEL_CUSTOM_THUMB_INFIXES', '-uae'); will handle custom thumbnails like image-uae-100x100.jpg;

define('SHORTPIXEL_USE_DOUBLE_WEBP_EXTENSION', true); define('SHORTPIXEL_USE_DOUBLE_AVIF_EXTENSION', true); will tell the plugin to create double extensions for the WebP/AVIF image counterparts, for example, image.jpg.webp/image.jpg.avif for image.jpg;

Enable the "Trusted mode" in case the file system has limitations and is very slow in responding to direct file operations by adding this constant:

define('SHORTPIXEL_TRUSTED_MODE', true);

This will simply skip file check operations and if the Media Library loads very slowly or freezes, you might want to try adding the constant above to your wp-config.php file.

Disable the feedback survey when the plugin is deactivated:

define('SHORTPIXEL_SKIP_FEEDBACK', true);

Hide the Cloudflare settings by defining these constants in wp-config.php:

define('SHORTPIXEL_CFTOKEN', 'the Cloudflare API token that has Purge Cache right'); define('SHORTPIXEL_CFZONE', 'The Zone ID from the domain settings in Cloudflare');

Add HTTP basic authentication credentials by defining these constants in wp-config.php

define('SHORTPIXEL_HTTP_AUTH_USER', 'user'); define('SHORTPIXEL_HTTP_AUTH_PASSWORD', 'pass');

== Screenshots ==

  1. Bulk optimization running. (Media>Bulk ShortPixel)

  2. Activate your API key in the plugin Settings. (Settings>ShortPixel)

  3. Check out the main settings after the API key is activated. (Settings>ShortPixel)

  4. Tweak it using Advanced settings. (Settings>ShortPixel)

  5. Compress all your past images with one click. (Media>Bulk ShortPixel)

  6. Check image optimization status, and restore or reoptimize the image. (Media>Library)

  7. Check image optimisation details. (Media>Library->Edit)

  8. Check other optimized images' status - themes or other plugins' images. (Media>Other Media)

== Changelog ==

= 5.6.4 = Release date: October 9, 2024

= 5.6.3 = Release date: July 16, 2024

= 5.6.2 = Release date: May 23, 2024

= 5.6.1 = Release date: May 21, 2024

= 5.6.0 = Release date: May 2, 2024

= 5.5.5 = Release date: February 13, 2024

= 5.5.4 = Release date: January 22, 2024

= 5.5.3 = Release date: January 3, 2024

= 5.5.2 = Release date: November 24, 2023

= 5.5.1 = Release date: November 17, 2023

= 5.5.0 = Release date: November 8, 2023

= 5.4.3 = Release date: September 28, 2023

= 5.4.2 = Release date: September 14, 2023

= 5.4.1 = Release date: September 4, 2023

= 5.4.0 = Release date: August 1, 2023

= 5.3.0 = Release date: June 27, 2023

= 5.2.3 = Release date: May 26, 2023

= 5.2.2 = Release date: May 10, 2023

= 5.2.1 = Release date February 21, 2023

= 5.2.0 = Release date February 15, 2023

= 5.1.6 = Release date December 31, 2022

= 5.1.5 = Release date November 29, 2022

= 5.1.4 = Release date November 28, 2022

= 5.1.3 = Release date November 9, 2022

= 5.1.2 = Release date November 7, 2022

= 5.1.1 = Release date October 20th, 2022

= 5.1.0 = Release date October 20th, 2022

= EARLIER VERSIONS =

== Upgrade Notice ==

= 5.0.0 =

= 4.22.9 =