536a37cd by Jeff Balicki

fix img

Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent c8722f63
/* This is based on jQuery UI */
#regenerate-thumbnails-app .ui-progressbar {
height: 2em;
text-align: center;
overflow: hidden;
}
#regenerate-thumbnails-app .ui-progressbar .ui-progressbar-value {
margin: -1px;
height: 100%;
transition-duration: 0.5s;
}
#regenerate-thumbnails-app .ui-widget.ui-widget-content {
border: 1px solid #c5dbec;
}
#regenerate-thumbnails-app .ui-widget-content {
border: 1px solid #a6c9e2;
background: #fcfdfd url("images/ui-bg_inset-hard_100_fcfdfd_1x100.png") 50% bottom repeat-x;
color: #222222;
}
#regenerate-thumbnails-app .ui-widget-header {
border: 1px solid #4297d7;
background: #5c9ccc url("images/ui-bg_gloss-wave_55_5c9ccc_500x100.png") 50% 50% repeat-x;
color: #ffffff;
font-weight: bold;
}
#regenerate-thumbnails-app .ui-corner-all {
border-radius: 5px;
}
#regenerate-thumbnails-app .ui-corner-left {
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
}
This diff could not be displayed because it is too large.
/*!
* Vue.js v2.6.11
* (c) 2014-2019 Evan You
* Released under the MIT License.
*/
<?php
/**
* Regenerate Thumbnails: REST API controller class
*
* @package RegenerateThumbnails
* @since 3.0.0
*/
/**
* Registers new REST API endpoints.
*
* @since 3.0.0
*/
class RegenerateThumbnails_REST_Controller extends WP_REST_Controller {
/**
* The namespace for the REST API routes.
*
* @since 3.0.0
*
* @var string
*/
public $namespace = 'regenerate-thumbnails/v1';
/**
* Register the new routes and endpoints.
*
* @since 3.0.0
*/
public function register_routes() {
register_rest_route( $this->namespace, '/regenerate/(?P<id>[\d]+)', array(
array(
'methods' => WP_REST_Server::ALLMETHODS,
'callback' => array( $this, 'regenerate_item' ),
'permission_callback' => array( $this, 'permissions_check' ),
'args' => array(
'only_regenerate_missing_thumbnails' => array(
'description' => __( "Whether to only regenerate missing thumbnails. It's faster with this enabled.", 'regenerate-thumbnails' ),
'type' => 'boolean',
'default' => true,
),
'delete_unregistered_thumbnail_files' => array(
'description' => __( 'Whether to delete any old, now unregistered thumbnail files.', 'regenerate-thumbnails' ),
'type' => 'boolean',
'default' => false,
),
'update_usages_in_posts' => array(
'description' => __( 'Whether to update the image tags in any posts that make use of this attachment.', 'regenerate-thumbnails' ),
'type' => 'boolean',
'default' => true,
),
'update_usages_in_posts_post_type' => array(
'description' => __( 'The types of posts to update. Defaults to all public post types.', 'regenerate-thumbnails' ),
'type' => 'array',
'default' => array(),
'validate_callback' => array( $this, 'is_array' ),
),
'update_usages_in_posts_post_ids' => array(
'description' => __( 'Specific post IDs to update rather than any posts that use this attachment.', 'regenerate-thumbnails' ),
'type' => 'array',
'default' => array(),
'validate_callback' => array( $this, 'is_array' ),
),
'update_usages_in_posts_posts_per_loop' => array(
'description' => __( "Posts to process per loop. This is to control memory usage and you likely don't need to adjust this.", 'regenerate-thumbnails' ),
'type' => 'integer',
'default' => 10,
'sanitize_callback' => 'absint',
),
),
),
) );
register_rest_route( $this->namespace, '/attachmentinfo/(?P<id>[\d]+)', array(
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'attachment_info' ),
'permission_callback' => array( $this, 'permissions_check' ),
),
) );
register_rest_route( $this->namespace, '/featuredimages', array(
array(
'methods' => WP_REST_Server::READABLE,
'callback' => array( $this, 'featured_images' ),
'permission_callback' => array( $this, 'permissions_check' ),
'args' => $this->get_paging_collection_params(),
),
) );
}
/**
* Register a filter to allow excluding site icons via a query parameter.
*
* @since 3.0.0
*/
public function register_filters() {
add_filter( 'rest_attachment_query', array( $this, 'maybe_filter_out_site_icons' ), 10, 2 );
add_filter( 'rest_attachment_query', array( $this, 'maybe_filter_mimes_types' ), 10, 2 );
}
/**
* If the exclude_site_icons parameter is set on a media (attachment) request,
* filter out any attachments that are or were being used as a site icon.
*
* @param array $args Key value array of query var to query value.
* @param WP_REST_Request $request The request used.
*
* @return array Key value array of query var to query value.
*/
public function maybe_filter_out_site_icons( $args, $request ) {
if ( empty( $request['exclude_site_icons'] ) ) {
return $args;
}
if ( ! isset( $args['meta_query'] ) ) {
$args['meta_query'] = array();
}
$args['meta_query'][] = array(
'key' => '_wp_attachment_context',
'value' => 'site-icon',
'compare' => 'NOT EXISTS',
);
return $args;
}
/**
* If the is_regeneratable parameter is set on a media (attachment) request,
* filter results to only include images and PDFs.
*
* @param array $args Key value array of query var to query value.
* @param WP_REST_Request $request The request used.
*
* @return array Key value array of query var to query value.
*/
public function maybe_filter_mimes_types( $args, $request ) {
if ( empty( $request['is_regeneratable'] ) ) {
return $args;
}
$args['post_mime_type'] = array();
foreach ( get_allowed_mime_types() as $mime_type ) {
if ( 'image/svg+xml' === $mime_type ) {
continue;
}
if ( 'application/pdf' == $mime_type || 'image/' == substr( $mime_type, 0, 6 ) ) {
$args['post_mime_type'][] = $mime_type;
}
}
return $args;
}
/**
* Retrieves the paging query params for the collections.
*
* @since 3.0.0
*
* @return array Query parameters for the collection.
*/
public function get_paging_collection_params() {
return array_intersect_key(
parent::get_collection_params(),
array_flip( array( 'page', 'per_page' ) )
);
}
/**
* Regenerate the thumbnails for a specific media item.
*
* @since 3.0.0
*
* @param WP_REST_Request $request Full data about the request.
*
* @return true|WP_Error True on success, otherwise a WP_Error object.
*/
public function regenerate_item( $request ) {
$regenerator = RegenerateThumbnails_Regenerator::get_instance( $request->get_param( 'id' ) );
if ( is_wp_error( $regenerator ) ) {
return $regenerator;
}
$result = $regenerator->regenerate( array(
'only_regenerate_missing_thumbnails' => $request->get_param( 'only_regenerate_missing_thumbnails' ),
'delete_unregistered_thumbnail_files' => $request->get_param( 'delete_unregistered_thumbnail_files' ),
) );
if ( is_wp_error( $result ) ) {
return $result;
}
if ( $request->get_param( 'update_usages_in_posts' ) ) {
$posts_updated = $regenerator->update_usages_in_posts( array(
'post_type' => $request->get_param( 'update_usages_in_posts_post_type' ),
'post_ids' => $request->get_param( 'update_usages_in_posts_post_ids' ),
'posts_per_loop' => $request->get_param( 'update_usages_in_posts_posts_per_loop' ),
) );
// If wp_update_post() failed for any posts, return that error.
foreach ( $posts_updated as $post_updated_result ) {
if ( is_wp_error( $post_updated_result ) ) {
return $post_updated_result;
}
}
}
return $this->attachment_info( $request );
}
/**
* Return a bunch of information about the current attachment for use in the UI
* including details about the thumbnails.
*
* @since 3.0.0
*
* @param WP_REST_Request $request Full data about the request.
*
* @return array|WP_Error The data array or a WP_Error object on error.
*/
public function attachment_info( $request ) {
$regenerator = RegenerateThumbnails_Regenerator::get_instance( $request->get_param( 'id' ) );
if ( is_wp_error( $regenerator ) ) {
return $regenerator;
}
return $regenerator->get_attachment_info();
}
/**
* Return attachment IDs that are being used as featured images.
*
* @since 3.0.0
*
* @param WP_REST_Request $request Full data about the request.
*
* @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
*/
public function featured_images( $request ) {
global $wpdb;
$page = $request->get_param( 'page' );
$per_page = $request->get_param( 'per_page' );
if ( 0 == $per_page ) {
$per_page = 10;
}
$featured_image_ids = $wpdb->get_results( $wpdb->prepare(
"SELECT SQL_CALC_FOUND_ROWS meta_value AS id FROM {$wpdb->postmeta} WHERE meta_key = '_thumbnail_id' GROUP BY meta_value ORDER BY MIN(meta_id) LIMIT %d OFFSET %d",
$per_page,
( $per_page * $page ) - $per_page
) );
$total = $wpdb->get_var( "SELECT FOUND_ROWS()" );
$max_pages = ceil( $total / $per_page );
if ( $page > $max_pages && $total > 0 ) {
return new WP_Error( 'rest_post_invalid_page_number', __( 'The page number requested is larger than the number of pages available.' ), array( 'status' => 400 ) );
}
$response = rest_ensure_response( $featured_image_ids );
$response->header( 'X-WP-Total', (int) $total );
$response->header( 'X-WP-TotalPages', (int) $max_pages );
$request_params = $request->get_query_params();
$base = add_query_arg( $request_params, rest_url( $this->namespace . '/featuredimages' ) );
if ( $page > 1 ) {
$prev_page = $page - 1;
if ( $prev_page > $max_pages ) {
$prev_page = $max_pages;
}
$prev_link = add_query_arg( 'page', $prev_page, $base );
$response->link_header( 'prev', $prev_link );
}
if ( $max_pages > $page ) {
$next_page = $page + 1;
$next_link = add_query_arg( 'page', $next_page, $base );
$response->link_header( 'next', $next_link );
}
return $response;
}
/**
* Check to see if the current user is allowed to use this endpoint.
*
* @since 3.0.0
*
* @param WP_REST_Request $request Full data about the request.
*
* @return bool Whether the current user has permission to regenerate thumbnails.
*/
public function permissions_check( $request ) {
return current_user_can( RegenerateThumbnails()->capability );
}
/**
* Returns whether a variable is an array or not. This is needed because 3 arguments are
* passed to validation callbacks but is_array() only accepts one argument.
*
* @since 3.0.0
*
* @see https://core.trac.wordpress.org/ticket/34659
*
* @param mixed $param The parameter value to validate.
* @param WP_REST_Request $request The REST request.
* @param string $key The parameter name.
*
* @return bool Whether the parameter is an array or not.
*/
public function is_array( $param, $request, $key ) {
return is_array( $param );
}
}
!function(a){function b(a){return a=b.buildAjaxOptions(a),b.transport(a)}var c=window.wpApiSettings;b.buildAjaxOptions=function(b){var d,e,f,g,h,i=b.url,j=b.path;if("string"==typeof b.namespace&&"string"==typeof b.endpoint&&(d=b.namespace.replace(/^\/|\/$/g,""),e=b.endpoint.replace(/^\//,""),j=e?d+"/"+e:d),"string"==typeof j&&(i=c.root+j.replace(/^\//,"")),g=!(b.data&&b.data._wpnonce),f=b.headers||{},g)for(h in f)if(f.hasOwnProperty(h)&&"x-wp-nonce"===h.toLowerCase()){g=!1;break}return g&&(f=a.extend({"X-WP-Nonce":c.nonce},f)),b=a.extend({},b,{headers:f,url:i}),delete b.path,delete b.namespace,delete b.endpoint,b},b.transport=a.ajax,window.wp=window.wp||{},window.wp.apiRequest=b}(jQuery);
\ No newline at end of file
=== Regenerate Thumbnails ===
Contributors: Viper007Bond
Tags: thumbnail, thumbnails, post thumbnail, post thumbnails
Requires at least: 4.7
Tested up to: 6.3
Requires PHP: 5.2.4
Stable tag: 3.1.6
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Regenerate the thumbnails for one or more of your image uploads. Useful when changing their sizes or your theme.
== Description ==
Regenerate Thumbnails allows you to regenerate all thumbnail sizes for one or more images that have been uploaded to your Media Library.
This is useful for situations such as:
* A new thumbnail size has been added and you want past uploads to have a thumbnail in that size.
* You've changed the dimensions of an existing thumbnail size, for example via Settings → Media.
* You've switched to a new WordPress theme that uses featured images of a different size.
It also offers the ability to delete old, unused thumbnails in order to free up server space.
= In Memory of Alex Mills =
In February 2019 Alex Mills, the author of this plugin, [passed away](https://alex.blog/2019/02/27/from-alexs-family/). He leaves behind a number of plugins which will be maintained by Automattic and members of the WordPress community. If this plugin is useful to you please consider donating to the Oregon Health and Science University. You can find more information [here](https://alex.blog/2019/03/13/in-memory-of-alex-donation-link-update/).
= Alternatives =
**WP-CLI**
If you have command line access to your server, I highly recommend using [WP-CLI](https://wp-cli.org/) instead of this plugin as it's faster (no HTTP requests overhead) and can be run inside of a `screen` for those with many thumbnails. For details, see the documentation of its [`media regenerate` command](https://developer.wordpress.org/cli/commands/media/regenerate/).
**Jetpack's Photon Module**
[Jetpack](https://jetpack.com/) is a plugin by Automattic, makers of WordPress.com. It gives your self-hosted WordPress site some of the functionality that is available to WordPress.com-hosted sites.
[The Photon module](https://jetpack.com/support/photon/) makes the images on your site be served from WordPress.com's global content delivery network (CDN) which should speed up the loading of images. Importantly though it can create thumbnails on the fly which means you'll never need to use this plugin.
I personally use Photon on my own website.
*Disclaimer: I work for Automattic but I would recommend Photon even if I didn't.*
= Need Help? Found A Bug? Want To Contribute Code? =
Support for this plugin is provided via the [WordPress.org forums](https://wordpress.org/support/plugin/regenerate-thumbnails).
The source code for this plugin is available on [GitHub](https://github.com/automattic/regenerate-thumbnails).
== Installation ==
1. Go to your admin area and select Plugins → Add New from the menu.
2. Search for "Regenerate Thumbnails".
3. Click install.
4. Click activate.
5. Navigate to Tools → Regenerate Thumbnails.
== Frequently Asked Questions ==
= Is this plugin [GDPR](https://en.wikipedia.org/wiki/General_Data_Protection_Regulation) compliant? =
This plugin does not log nor transmit any user data. Infact it doesn't even do anything on the user-facing part of your website, only in the admin area. This means it should be compliant but I'm not a lawyer.
== Screenshots ==
1. The main plugin interface.
2. Regenerating in progress.
3. Interface for regenerating a single attachment.
4. Individual images can be regenerated from the media library in list view.
5. They can also be regenerated from the edit attachment screen.
== ChangeLog ==
= Version 3.1.6 =
* Fix: Respect "Skip regenerating existing correctly sized thumbnails" setting.
* Fix: Don't delete all thumbnails when deleting old unregistered thumbnails size.
= Version 3.1.5 =
* Fix: Don't overwrite 'All X Attachment' button label with featured images count.
* Tested successfully with PHP 8.1.
* Tested successfully with PHP 8.2.
= Version 3.1.4 =
* Fix: Don't attempt to regenerate SVG's.
* Bump tested version.
* Update dependencies.
= Version 3.1.3 =
* Update plugin dependencies to the latest version.
= Version 3.1.2 =
* Use wp_get_original_image_path() in WordPress 5.3
= Version 3.1.1 =
* Minor fix to avoid a divide by zero error when displaying thumbnail filenames.
= Version 3.1.0 =
* Bring back the ability to delete old, unregistered thumbnail sizes. Support for updating post contents is still disabled (too buggy).
* Various code improvements including string localization disambiguation.
= Version 3.0.2 =
* Fix slowdown in certain cases in the media library.
* Fix not being able to regenerate existing thumbnails for single images. Props @idofri.
* Fix JavaScript error that could occur if the REST API response was unexpected (empty or PHP error).
* Fix bug related to multibyte filenames.
* If an image is used as the featured image on multiple posts, only regenerate it once instead of once per post.
= Version 3.0.1 =
* Temporarily disable the update post functionality. I tested it a lot but it seems there's still some bugs.
* Temporarily disable the delete old thumbnails functionality. It seems to work fine but without the update post functionality, it's not as useful.
* Try to more gracefully handle cases where there's missing metadata for attachments.
* Wait until `init` to initialize the plugin so themes can filter the plugin's capability. `plugins_loaded` is too early.
* Fix a JavaScript error that would cause the whole regeneration process to stop if an individual image returned non-JSON, such as a 500 error code.
* Accept GET requests for the regenerate REST API endpoint instead of just POSTs. For some reasons some people's sites are using GET despite the code saying use POST.
* Make the attachment ID clickable in error messages.
* Fetch 25 attachments at a time instead of 5. I was using 5 for testing.
* PHP notice fixes.
= Version 3.0.0 =
* Complete rewrite from scratch using Vue.js and the WordPress REST API.
= Version 2.2.4 =
* Better AJAX response error handling in the JavaScript. This should fix a long-standing bug in this plugin. Props Hew Sutton.
= Version 2.2.3 =
* Make the capability required to use this plugin filterable so themes and other plugins can change it. Props [Jackson Whelan](http://jacksonwhelan.com/).
= Version 2.2.2 =
* Don't check the nonce until we're sure that the action called was for this plugin. Fixes lots of "Are you sure you want to do this?" error messages.
= Version 2.2.1 =
* Fix the bottom bulk action dropdown. Thanks Stefan for pointing out the issue!
= Version 2.2.0 =
* Changes to the Bulk Action functionality were made shortly before the release of WordPress 3.1 which broke the way I implemented the specific multiple image regeneration feature. This version adds to the Bulk Action menu using Javascript as that's the only way to do it currently.
= Version 2.1.3 =
* Move the `error_reporting()` call in the AJAX handler to the beginning so that we're more sure that no PHP errors are outputted. Some hosts disable usage of `set_time_limit()` and calling it was causing a PHP warning to be outputted.
= Version 2.1.2 =
* When regenerating all images, newest images are done first rather than the oldest.
* Fixed a bug with regeneration error reporting in some browsers. Thanks to pete-sch for reporting the error.
* Supress PHP errors in the AJAX handler to avoid sending an invalid JSON response. Thanks to pete-sch for reporting the error.
* Better and more detailed error reporting for when `wp_generate_attachment_metadata()` fails.
= Version 2.1.1 =
* Clean up the wording a bit to better match the new features and just be easier to understand.
* Updated screenshots.
= Version 2.1.0 =
Lots of new features!
* Thanks to a lot of jQuery help from [Boris Schapira](http://borisschapira.com/), a failed image regeneration will no longer stop the whole process.
* The results of each image regeneration is now outputted. You can easily see which images were successfully regenerated and which failed. Was inspired by a concept by Boris.
* There is now a button on the regeneration page that will allow you to abort resizing images for any reason. Based on code by Boris.
* You can now regenerate single images from the Media page. The link to do so will show up in the actions list when you hover over the row.
* You can now bulk regenerate multiple from the Media page. Check the boxes and then select "Regenerate Thumbnails" form the "Bulk Actions" dropdown. WordPress 3.1+ only.
* The total time that the regeneration process took is now displayed in the final status message.
* jQuery UI Progressbar version upgraded.
= Version 2.0.3 =
* Switch out deprecated function call.
= Version 2.0.2 =
* Directly query the database to only fetch what the plugin needs (the attachment ID). This will reduce the memory required as it's not storing the whole row for each attachment.
= Version 2.0.1 =
* I accidentally left a `check_admin_referer()` (nonce check) commented out.
= Version 2.0.0 =
* Recoded from scratch. Now uses an AJAX request per attachment to do the resizing. No more PHP maximum execution time errors or anything like that. Also features a pretty progress bar to let the user know how it's going.
= Version 1.1.0 =
* WordPress 2.7 updates -- code + UI. Thanks to jdub and Patrick F.
= Version 1.0.0 =
* Initial release.
= Upgrade Notice =
Support for WordPress 5.3