Sync plugins from current page
Signed-off-by: Adrian Nöthlich <git@promasu.tech>
This commit is contained in:
26
wp-content/plugins/imsanity/.travis.yml
Normal file
26
wp-content/plugins/imsanity/.travis.yml
Normal file
@@ -0,0 +1,26 @@
|
||||
sudo: false
|
||||
|
||||
language: php
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: never
|
||||
on_failure: change
|
||||
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
|
||||
php:
|
||||
- 7.3
|
||||
|
||||
env:
|
||||
- WP_VERSION=latest WP_MULTISITE=0
|
||||
|
||||
before_script:
|
||||
- export PATH="$HOME/.config/composer/vendor/bin:$PATH"
|
||||
- phpenv config-rm xdebug.ini
|
||||
- composer global require wp-coding-standards/wpcs dealerdirect/phpcodesniffer-composer-installer
|
||||
|
||||
script:
|
||||
- phpcs --standard=phpcs.ruleset.xml --extensions=php .
|
||||
248
wp-content/plugins/imsanity/ajax.php
Normal file
248
wp-content/plugins/imsanity/ajax.php
Normal file
@@ -0,0 +1,248 @@
|
||||
<?php
|
||||
/**
|
||||
* Imsanity AJAX functions.
|
||||
*
|
||||
* @package Imsanity
|
||||
*/
|
||||
|
||||
add_action( 'wp_ajax_imsanity_get_images', 'imsanity_get_images' );
|
||||
add_action( 'wp_ajax_imsanity_resize_image', 'imsanity_resize_image' );
|
||||
|
||||
/**
|
||||
* Verifies that the current user has administrator permission and, if not,
|
||||
* renders a json warning and dies
|
||||
*/
|
||||
function imsanity_verify_permission() {
|
||||
if ( ! current_user_can( 'activate_plugins' ) ) { // this isn't a real capability, but super admins can do anything, so it works.
|
||||
die(
|
||||
json_encode(
|
||||
array(
|
||||
'success' => false,
|
||||
'message' => esc_html__( 'Administrator permission is required', 'imsanity' ),
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'imsanity-bulk' ) ) {
|
||||
die(
|
||||
json_encode(
|
||||
array(
|
||||
'success' => false,
|
||||
'message' => esc_html__( 'Access token has expired, please reload the page.', 'imsanity' ),
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Searches for up to 250 images that are candidates for resize and renders them
|
||||
* to the browser as a json array, then dies
|
||||
*/
|
||||
function imsanity_get_images() {
|
||||
imsanity_verify_permission();
|
||||
|
||||
global $wpdb;
|
||||
$offset = 0;
|
||||
$limit = apply_filters( 'imsanity_attachment_query_limit', 3000 );
|
||||
$results = array();
|
||||
$maxw = imsanity_get_option( 'imsanity_max_width', IMSANITY_DEFAULT_MAX_WIDTH );
|
||||
$maxh = imsanity_get_option( 'imsanity_max_height', IMSANITY_DEFAULT_MAX_HEIGHT );
|
||||
$count = 0;
|
||||
|
||||
$images = $wpdb->get_results( $wpdb->prepare( "SELECT metas.meta_value as file_meta,metas.post_id as ID FROM $wpdb->postmeta metas INNER JOIN $wpdb->posts posts ON posts.ID = metas.post_id WHERE posts.post_type = 'attachment' AND posts.post_mime_type LIKE %s AND posts.post_mime_type != 'image/bmp' AND metas.meta_key = '_wp_attachment_metadata' ORDER BY ID DESC LIMIT %d,%d", '%image%', $offset, $limit ) );
|
||||
/* $images = $wpdb->get_results( "SELECT metas.meta_value as file_meta,metas.post_id as ID FROM $wpdb->postmeta metas INNER JOIN $wpdb->posts posts ON posts.ID = metas.post_id WHERE posts.post_type LIKE 'attachment' AND posts.post_mime_type LIKE 'image%%' AND posts.post_mime_type NOT LIKE 'image/bmp' AND metas.meta_key = '_wp_attachment_metadata' LIMIT $offset,$limit" ); */
|
||||
while ( $images ) {
|
||||
|
||||
foreach ( $images as $image ) {
|
||||
$imagew = false;
|
||||
$imageh = false;
|
||||
|
||||
$meta = unserialize( $image->file_meta );
|
||||
|
||||
// If "noresize" is included in the filename then we will bypass imsanity scaling.
|
||||
if ( ! empty( $meta['file'] ) && strpos( $meta['file'], 'noresize' ) !== false ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( imsanity_get_option( 'imsanity_deep_scan', false ) ) {
|
||||
$file_path = imsanity_attachment_path( $meta, $image->ID, '', false );
|
||||
if ( $file_path ) {
|
||||
list( $imagew, $imageh ) = getimagesize( $file_path );
|
||||
}
|
||||
}
|
||||
if ( empty( $imagew ) || empty( $imageh ) ) {
|
||||
$imagew = $meta['width'];
|
||||
$imageh = $meta['height'];
|
||||
}
|
||||
|
||||
if ( $imagew > $maxw || $imageh > $maxh ) {
|
||||
$count++;
|
||||
|
||||
$results[] = array(
|
||||
'id' => $image->ID,
|
||||
'width' => $imagew,
|
||||
'height' => $imageh,
|
||||
'file' => $meta['file'],
|
||||
);
|
||||
}
|
||||
|
||||
// Make sure we only return a limited number of records so we don't overload the ajax features.
|
||||
if ( $count >= IMSANITY_AJAX_MAX_RECORDS ) {
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
$offset += $limit;
|
||||
$images = $wpdb->get_results( $wpdb->prepare( "SELECT metas.meta_value as file_meta,metas.post_id as ID FROM $wpdb->postmeta metas INNER JOIN $wpdb->posts posts ON posts.ID = metas.post_id WHERE posts.post_type = 'attachment' AND posts.post_mime_type LIKE %s AND posts.post_mime_type != 'image/bmp' AND metas.meta_key = '_wp_attachment_metadata' ORDER BY ID DESC LIMIT %d,%d", '%image%', $offset, $limit ) );
|
||||
} // endwhile
|
||||
die( json_encode( $results ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Resizes the image with the given id according to the configured max width and height settings
|
||||
* renders a json response indicating success/failure and dies
|
||||
*/
|
||||
function imsanity_resize_image() {
|
||||
imsanity_verify_permission();
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$id = (int) $_POST['id'];
|
||||
|
||||
if ( ! $id ) {
|
||||
die(
|
||||
json_encode(
|
||||
array(
|
||||
'success' => false,
|
||||
'message' => esc_html__( 'Missing ID Parameter', 'imsanity' ),
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$meta = wp_get_attachment_metadata( $id );
|
||||
|
||||
if ( $meta && is_array( $meta ) ) {
|
||||
$uploads = wp_upload_dir();
|
||||
$oldpath = imsanity_attachment_path( $meta['file'], $id, '', false );
|
||||
if ( empty( $oldpath ) || ! is_writable( $oldpath ) ) {
|
||||
/* translators: %s: File-name of the image */
|
||||
$msg = sprintf( esc_html__( '%s is not writable', 'imsanity' ), $meta['file'] );
|
||||
die(
|
||||
json_encode(
|
||||
array(
|
||||
'success' => false,
|
||||
'message' => $msg,
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$maxw = imsanity_get_option( 'imsanity_max_width', IMSANITY_DEFAULT_MAX_WIDTH );
|
||||
$maxh = imsanity_get_option( 'imsanity_max_height', IMSANITY_DEFAULT_MAX_HEIGHT );
|
||||
|
||||
// method one - slow but accurate, get file size from file itself.
|
||||
list( $oldw, $oldh ) = getimagesize( $oldpath );
|
||||
// method two - get file size from meta, fast but resize will fail if meta is out of sync.
|
||||
if ( ! $oldw || ! $oldh ) {
|
||||
$oldw = $meta['width'];
|
||||
$oldh = $meta['height'];
|
||||
}
|
||||
|
||||
if ( ( $oldw > $maxw && $maxw > 0 ) || ( $oldh > $maxh && $maxh > 0 ) ) {
|
||||
$quality = imsanity_get_option( 'imsanity_quality', IMSANITY_DEFAULT_QUALITY );
|
||||
|
||||
if ( $oldw > $maxw && $maxw > 0 && $oldh > $maxh && $maxh > 0 && apply_filters( 'imsanity_crop_image', false ) ) {
|
||||
$neww = $maxw;
|
||||
$newh = $maxh;
|
||||
} else {
|
||||
list( $neww, $newh ) = wp_constrain_dimensions( $oldw, $oldh, $maxw, $maxh );
|
||||
}
|
||||
|
||||
$resizeresult = imsanity_image_resize( $oldpath, $neww, $newh, apply_filters( 'imsanity_crop_image', false ), null, null, $quality );
|
||||
|
||||
if ( $resizeresult && ! is_wp_error( $resizeresult ) ) {
|
||||
$newpath = $resizeresult;
|
||||
|
||||
if ( $newpath !== $oldpath && is_file( $newpath ) && filesize( $newpath ) < filesize( $oldpath ) ) {
|
||||
// we saved some file space. remove original and replace with resized image.
|
||||
unlink( $oldpath );
|
||||
rename( $newpath, $oldpath );
|
||||
$meta['width'] = $neww;
|
||||
$meta['height'] = $newh;
|
||||
|
||||
wp_update_attachment_metadata( $id, $meta );
|
||||
|
||||
$results = array(
|
||||
'success' => true,
|
||||
'id' => $id,
|
||||
/* translators: %s: File-name of the image */
|
||||
'message' => sprintf( esc_html__( 'OK: %s', 'imsanity' ), $oldpath ),
|
||||
);
|
||||
} elseif ( $newpath !== $oldpath ) {
|
||||
// the resized image is actually bigger in filesize (most likely due to jpg quality).
|
||||
// keep the old one and just get rid of the resized image.
|
||||
if ( is_file( $newpath ) ) {
|
||||
unlink( $newpath );
|
||||
}
|
||||
$results = array(
|
||||
'success' => false,
|
||||
'id' => $id,
|
||||
/* translators: 1: File-name of the image 2: the error message, translated elsewhere */
|
||||
'message' => sprintf( esc_html__( 'ERROR: %1$s (%2$s)', 'imsanity' ), $oldpath, esc_html__( 'Resized image was larger than the original', 'imsanity' ) ),
|
||||
);
|
||||
} else {
|
||||
$results = array(
|
||||
'success' => false,
|
||||
'id' => $id,
|
||||
/* translators: 1: File-name of the image 2: the error message, translated elsewhere */
|
||||
'message' => sprintf( esc_html__( 'ERROR: %1$s (%2$s)', 'imsanity' ), $oldpath, esc_html__( 'Unknown error, resizing function returned the same filename', 'imsanity' ) ),
|
||||
);
|
||||
}
|
||||
} elseif ( false === $resizeresult ) {
|
||||
$results = array(
|
||||
'success' => false,
|
||||
'id' => $id,
|
||||
/* translators: 1: File-name of the image 2: the error message, translated elsewhere */
|
||||
'message' => sprintf( esc_html__( 'ERROR: %1$s (%2$s)', 'imsanity' ), $oldpath, esc_html__( 'wp_get_image_editor missing', 'imsanity' ) ),
|
||||
);
|
||||
} else {
|
||||
$results = array(
|
||||
'success' => false,
|
||||
'id' => $id,
|
||||
/* translators: 1: File-name of the image 2: the error message, translated elsewhere */
|
||||
'message' => sprintf( esc_html__( 'ERROR: %1$s (%2$s)', 'imsanity' ), $oldpath, htmlentities( $resizeresult->get_error_message() ) ),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$results = array(
|
||||
'success' => true,
|
||||
'id' => $id,
|
||||
/* translators: %s: File-name of the image */
|
||||
'message' => sprintf( esc_html__( 'SKIPPED: %s (Resize not required)', 'imsanity' ), $oldpath ) . " -- $oldw x $oldh",
|
||||
);
|
||||
if ( empty( $meta['width'] ) || empty( $meta['height'] ) ) {
|
||||
if ( empty( $meta['width'] ) || $meta['width'] > $oldw ) {
|
||||
$meta['width'] = $oldw;
|
||||
}
|
||||
if ( empty( $meta['height'] ) || $meta['height'] > $oldh ) {
|
||||
$meta['height'] = $oldh;
|
||||
}
|
||||
wp_update_attachment_metadata( $id, $meta );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$results = array(
|
||||
'success' => false,
|
||||
'id' => $id,
|
||||
/* translators: %s: ID number of the image */
|
||||
'message' => sprintf( esc_html__( 'ERROR: Attachment with ID of %d not found', 'imsanity' ), intval( $id ) ),
|
||||
);
|
||||
}
|
||||
|
||||
// If there is a quota we need to reset the directory size cache so it will re-calculate.
|
||||
delete_transient( 'dirsize_cache' );
|
||||
|
||||
die( json_encode( $results ) );
|
||||
}
|
||||
74
wp-content/plugins/imsanity/changelog.txt
Normal file
74
wp-content/plugins/imsanity/changelog.txt
Normal file
@@ -0,0 +1,74 @@
|
||||
= 2.4.3 =
|
||||
* changed: default size from 2048 to 1920
|
||||
* fixed: WP Import plugin breaks during Media imports
|
||||
* fixed: setting a value to 0 causes errors on multi-site installs
|
||||
* fixed: conversion settings not displaying correctly on multi-site
|
||||
|
||||
= 2.4.2 =
|
||||
* changed: noresize in filename also works in batch processing
|
||||
* fixed: error message does not contain filename when file is missing
|
||||
* fixed: notice on network settings when deep scan option has not been set before
|
||||
|
||||
= 2.4.1 =
|
||||
* fixed: bulk resizer scan returning incorrect results
|
||||
* fixed: sprintf error during resizing and upload
|
||||
|
||||
= 2.4.0 =
|
||||
* added: deep scanning option for when attachment metadata isn't updating properly
|
||||
* fixed: uploads from Gutenberg not detected properly
|
||||
* fixed: some other plugin(s) trying to muck with the Imsanity settings links and breaking things
|
||||
* fixed: undefined notice for query during ajax operation
|
||||
* fixed: stale metadata could prevent further resizing
|
||||
|
||||
= 2.3.9 =
|
||||
* fixed: PNG to JPG filled transparency with black instead of white
|
||||
* fixed: auto-rotation causes incorrect scaling
|
||||
* fixed: results box stops scrolling at line 28
|
||||
* added: pre-emptive checks on file parameter to prevent read errors with getimagesize()
|
||||
|
||||
= 2.3.8 =
|
||||
* added: 'imsanity_crop_image' filter to crop images during resizing
|
||||
* added: increased security of network settings and AJAX requests
|
||||
* changed: metadata fetch and update use correct functions instead of direct database queries
|
||||
* changed: bulk resize search is kinder to your database
|
||||
* fixed: bulk resize could produce a larger image
|
||||
* fixed: image file permissions not checked prior to resizing
|
||||
* fixed: EWWW Image Optimizer optimizes image during resizing instead of waiting for metadata generation
|
||||
* fixed: JPG quality not displaying correctly on network/multisite settings page
|
||||
* fixed: some strings were not translatable
|
||||
* fixed: bulk resize results container was not scrollable
|
||||
* removed: legacy resize function for WP lower than 3.5
|
||||
|
||||
= 2.3.7 =
|
||||
* fixed: uploads to Media Library not detected properly
|
||||
* changed: default JPG quality is now 82, to match the WordPress default
|
||||
* changed: fr_FR and ru_RU moved to WP.org language packs
|
||||
* changed: new maintainer
|
||||
|
||||
= 2.3.6 =
|
||||
* tested up to WP 4.4
|
||||
* if resized image is not smaller than original, then keep original
|
||||
* allow IMSANITY_AJAX_MAX_RECORDS to be overridden in wp-config.php
|
||||
* if png-to-jpg is enabled, replace png transparency with white
|
||||
|
||||
= 2.3.5 =
|
||||
* Add option to hide Imsanity girl logo image on settings screen
|
||||
|
||||
= 2.3.4 =
|
||||
* Security update to network settings page
|
||||
|
||||
= 2.3.3 =
|
||||
* Update default size from 1024 to 2048
|
||||
* Tested up to WordPress 4.1.1
|
||||
* Move screenshots to /assets folder
|
||||
* Added 256x256 icon
|
||||
|
||||
= 2.3.2 =
|
||||
* Add PNG-To-JPG Option thanks to Jody Nesbitt
|
||||
|
||||
= 2.3.1 =
|
||||
* ignore errors if EXIF data is not readable
|
||||
* show counter when bulk resizing images
|
||||
|
||||
= 2.3.0 =
|
||||
* fix for incorrectly identifying media uploads as coming from 'other' on WP 4+
|
||||
BIN
wp-content/plugins/imsanity/images/ajax-loader.gif
Normal file
BIN
wp-content/plugins/imsanity/images/ajax-loader.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.7 KiB |
269
wp-content/plugins/imsanity/imsanity.php
Normal file
269
wp-content/plugins/imsanity/imsanity.php
Normal file
@@ -0,0 +1,269 @@
|
||||
<?php
|
||||
/**
|
||||
* Main file for Imsanity plugin.
|
||||
*
|
||||
* This file includes the core of Imsanity and the top-level image handler.
|
||||
*
|
||||
* @link https://wordpress.org/plugins/imsanity/
|
||||
* @package Imsanity
|
||||
*/
|
||||
|
||||
/*
|
||||
Plugin Name: Imsanity
|
||||
Plugin URI: https://wordpress.org/plugins/imsanity/
|
||||
Description: Imsanity stops insanely huge image uploads
|
||||
Author: Exactly WWW
|
||||
Text Domain: imsanity
|
||||
Version: 2.4.3
|
||||
Author URI: https://ewww.io/
|
||||
License: GPLv3
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
define( 'IMSANITY_VERSION', '2.4.3' );
|
||||
define( 'IMSANITY_SCHEMA_VERSION', '1.1' );
|
||||
|
||||
define( 'IMSANITY_DEFAULT_MAX_WIDTH', 1920 );
|
||||
define( 'IMSANITY_DEFAULT_MAX_HEIGHT', 1920 );
|
||||
define( 'IMSANITY_DEFAULT_BMP_TO_JPG', 1 );
|
||||
define( 'IMSANITY_DEFAULT_PNG_TO_JPG', 0 );
|
||||
define( 'IMSANITY_DEFAULT_QUALITY', 82 );
|
||||
|
||||
define( 'IMSANITY_SOURCE_POST', 1 );
|
||||
define( 'IMSANITY_SOURCE_LIBRARY', 2 );
|
||||
define( 'IMSANITY_SOURCE_OTHER', 4 );
|
||||
|
||||
if ( ! defined( 'IMSANITY_AJAX_MAX_RECORDS' ) ) {
|
||||
define( 'IMSANITY_AJAX_MAX_RECORDS', 250 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Load translations for Imsanity.
|
||||
*/
|
||||
function imsanity_init() {
|
||||
load_plugin_textdomain( 'imsanity', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Import supporting libraries.
|
||||
*/
|
||||
include_once( plugin_dir_path( __FILE__ ) . 'libs/utils.php' );
|
||||
include_once( plugin_dir_path( __FILE__ ) . 'settings.php' );
|
||||
include_once( plugin_dir_path( __FILE__ ) . 'ajax.php' );
|
||||
|
||||
/**
|
||||
* Inspects the request and determines where the upload came from.
|
||||
*
|
||||
* @return IMSANITY_SOURCE_POST | IMSANITY_SOURCE_LIBRARY | IMSANITY_SOURCE_OTHER
|
||||
*/
|
||||
function imsanity_get_source() {
|
||||
$id = array_key_exists( 'post_id', $_REQUEST ) ? (int) $_REQUEST['post_id'] : '';
|
||||
$action = array_key_exists( 'action', $_REQUEST ) ? $_REQUEST['action'] : '';
|
||||
|
||||
// A post_id indicates image is attached to a post.
|
||||
if ( $id > 0 ) {
|
||||
return IMSANITY_SOURCE_POST;
|
||||
}
|
||||
|
||||
// If the referrer is the post editor, that's a good indication the image is attached to a post.
|
||||
if ( ! empty( $_SERVER['HTTP_REFERER'] ) && strpos( $_SERVER['HTTP_REFERER'], '/post.php' ) ) {
|
||||
return IMSANITY_SOURCE_POST;
|
||||
}
|
||||
|
||||
// Post_id of 0 is 3.x otherwise use the action parameter.
|
||||
if ( 0 === $id || 'upload-attachment' === $action ) {
|
||||
return IMSANITY_SOURCE_LIBRARY;
|
||||
}
|
||||
|
||||
// We don't know where this one came from but $_REQUEST['_wp_http_referer'] may contain info.
|
||||
return IMSANITY_SOURCE_OTHER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the source, returns the max width/height.
|
||||
*
|
||||
* @example: list( $w, $h ) = imsanity_get_max_width_height( IMSANITY_SOURCE_LIBRARY );
|
||||
* @param int $source One of IMSANITY_SOURCE_POST | IMSANITY_SOURCE_LIBRARY | IMSANITY_SOURCE_OTHER.
|
||||
*/
|
||||
function imsanity_get_max_width_height( $source ) {
|
||||
$w = imsanity_get_option( 'imsanity_max_width', IMSANITY_DEFAULT_MAX_WIDTH );
|
||||
$h = imsanity_get_option( 'imsanity_max_height', IMSANITY_DEFAULT_MAX_HEIGHT );
|
||||
|
||||
switch ( $source ) {
|
||||
case IMSANITY_SOURCE_POST:
|
||||
break;
|
||||
case IMSANITY_SOURCE_LIBRARY:
|
||||
$w = imsanity_get_option( 'imsanity_max_width_library', $w );
|
||||
$h = imsanity_get_option( 'imsanity_max_height_library', $h );
|
||||
break;
|
||||
default:
|
||||
$w = imsanity_get_option( 'imsanity_max_width_other', $w );
|
||||
$h = imsanity_get_option( 'imsanity_max_height_other', $h );
|
||||
break;
|
||||
}
|
||||
|
||||
return array( $w, $h );
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler after a file has been uploaded. If the file is an image, check the size
|
||||
* to see if it is too big and, if so, resize and overwrite the original.
|
||||
*
|
||||
* @param Array $params The parameters submitted with the upload.
|
||||
*/
|
||||
function imsanity_handle_upload( $params ) {
|
||||
|
||||
// If "noresize" is included in the filename then we will bypass imsanity scaling.
|
||||
if ( strpos( $params['file'], 'noresize' ) !== false ) {
|
||||
return $params;
|
||||
}
|
||||
|
||||
// If preferences specify so then we can convert an original bmp or png file into jpg.
|
||||
if ( 'image/bmp' === $params['type'] && imsanity_get_option( 'imsanity_bmp_to_jpg', IMSANITY_DEFAULT_BMP_TO_JPG ) ) {
|
||||
$params = imsanity_convert_to_jpg( 'bmp', $params );
|
||||
}
|
||||
|
||||
if ( 'image/png' === $params['type'] && imsanity_get_option( 'imsanity_png_to_jpg', IMSANITY_DEFAULT_PNG_TO_JPG ) ) {
|
||||
$params = imsanity_convert_to_jpg( 'png', $params );
|
||||
}
|
||||
|
||||
// Make sure this is a type of image that we want to convert and that it exists.
|
||||
$oldpath = $params['file'];
|
||||
|
||||
if ( ( ! is_wp_error( $params ) ) && is_file( $oldpath ) && is_readable( $oldpath ) && is_writable( $oldpath ) && filesize( $oldpath ) > 0 && in_array( $params['type'], array( 'image/png', 'image/gif', 'image/jpeg' ), true ) ) {
|
||||
|
||||
// figure out where the upload is coming from.
|
||||
$source = imsanity_get_source();
|
||||
|
||||
list( $maxw,$maxh ) = imsanity_get_max_width_height( $source );
|
||||
|
||||
list( $oldw, $oldh ) = getimagesize( $oldpath );
|
||||
|
||||
if ( ( $oldw > $maxw && $maxw > 0 ) || ( $oldh > $maxh && $maxh > 0 ) ) {
|
||||
$quality = imsanity_get_option( 'imsanity_quality', IMSANITY_DEFAULT_QUALITY );
|
||||
|
||||
$ftype = imsanity_quick_mimetype( $oldpath );
|
||||
$orientation = imsanity_get_orientation( $oldpath, $ftype );
|
||||
// If we are going to rotate the image 90 degrees during the resize, swap the existing image dimensions.
|
||||
if ( 6 === (int) $orientation || 8 === (int) $orientation ) {
|
||||
$old_oldw = $oldw;
|
||||
$oldw = $oldh;
|
||||
$oldh = $old_oldw;
|
||||
}
|
||||
|
||||
if ( $oldw > $maxw && $maxw > 0 && $oldh > $maxh && $maxh > 0 && apply_filters( 'imsanity_crop_image', false ) ) {
|
||||
$neww = $maxw;
|
||||
$newh = $maxh;
|
||||
} else {
|
||||
list( $neww, $newh ) = wp_constrain_dimensions( $oldw, $oldh, $maxw, $maxh );
|
||||
}
|
||||
|
||||
remove_filter( 'wp_image_editors', 'ewww_image_optimizer_load_editor', 60 );
|
||||
$resizeresult = imsanity_image_resize( $oldpath, $neww, $newh, apply_filters( 'imsanity_crop_image', false ), null, null, $quality );
|
||||
if ( function_exists( 'ewww_image_optimizer_load_editor' ) ) {
|
||||
add_filter( 'wp_image_editors', 'ewww_image_optimizer_load_editor', 60 );
|
||||
}
|
||||
|
||||
if ( $resizeresult && ! is_wp_error( $resizeresult ) ) {
|
||||
$newpath = $resizeresult;
|
||||
|
||||
if ( is_file( $newpath ) && filesize( $newpath ) < filesize( $oldpath ) ) {
|
||||
// we saved some file space. remove original and replace with resized image.
|
||||
unlink( $oldpath );
|
||||
rename( $newpath, $oldpath );
|
||||
} elseif ( is_file( $newpath ) ) {
|
||||
// theresized image is actually bigger in filesize (most likely due to jpg quality).
|
||||
// keep the old one and just get rid of the resized image.
|
||||
unlink( $newpath );
|
||||
}
|
||||
} elseif ( false === $resizeresult ) {
|
||||
return $params;
|
||||
} elseif ( is_wp_error( $resizeresult ) ) {
|
||||
// resize didn't work, likely because the image processing libraries are missing.
|
||||
// remove the old image so we don't leave orphan files hanging around.
|
||||
unlink( $oldpath );
|
||||
|
||||
$params = wp_handle_upload_error(
|
||||
$oldpath,
|
||||
sprintf(
|
||||
/* translators: 1: error message 2: link to support forums */
|
||||
esc_html__( 'Imsanity was unable to resize this image for the following reason: %1$s. If you continue to see this error message, you may need to install missing server components. If you think you have discovered a bug, please report it on the Imsanity support forum: %2$s', 'imsanity' ),
|
||||
$resizeresult->get_error_message(),
|
||||
'https://wordpress.org/support/plugin/imsanity'
|
||||
)
|
||||
);
|
||||
} else {
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
}
|
||||
clearstatcache();
|
||||
return $params;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Read in the image file from the params and then save as a new jpg file.
|
||||
* if successful, remove the original image and alter the return
|
||||
* parameters to return the new jpg instead of the original
|
||||
*
|
||||
* @param string $type Type of the image to be converted: 'bmp' or 'png'.
|
||||
* @param array $params The upload parameters.
|
||||
* @return array altered params
|
||||
*/
|
||||
function imsanity_convert_to_jpg( $type, $params ) {
|
||||
|
||||
$img = null;
|
||||
|
||||
if ( 'bmp' === $type ) {
|
||||
include_once( 'libs/imagecreatefrombmp.php' );
|
||||
$img = imagecreatefrombmp( $params['file'] );
|
||||
} elseif ( 'png' === $type ) {
|
||||
if ( ! function_exists( 'imagecreatefrompng' ) ) {
|
||||
return wp_handle_upload_error( $params['file'], esc_html__( 'Imsanity requires the GD library to convert PNG images to JPG', 'imsanity' ) );
|
||||
}
|
||||
|
||||
$input = imagecreatefrompng( $params['file'] );
|
||||
// convert png transparency to white.
|
||||
$img = imagecreatetruecolor( imagesx( $input ), imagesy( $input ) );
|
||||
imagefill( $img, 0, 0, imagecolorallocate( $img, 255, 255, 255 ) );
|
||||
imagealphablending( $img, true );
|
||||
imagecopy( $img, $input, 0, 0, 0, 0, imagesx( $input ), imagesy( $input ) );
|
||||
} else {
|
||||
return wp_handle_upload_error( $params['file'], esc_html__( 'Unknown image type specified in imsanity_convert_to_jpg', 'imsanity' ) );
|
||||
}
|
||||
|
||||
// We need to change the extension from the original to .jpg so we have to ensure it will be a unique filename.
|
||||
$uploads = wp_upload_dir();
|
||||
$oldfilename = basename( $params['file'] );
|
||||
$newfilename = basename( str_ireplace( '.' . $type, '.jpg', $oldfilename ) );
|
||||
$newfilename = wp_unique_filename( $uploads['path'], $newfilename );
|
||||
|
||||
$quality = imsanity_get_option( 'imsanity_quality', IMSANITY_DEFAULT_QUALITY );
|
||||
|
||||
if ( imagejpeg( $img, $uploads['path'] . '/' . $newfilename, $quality ) ) {
|
||||
// Conversion succeeded: remove the original bmp & remap the params.
|
||||
unlink( $params['file'] );
|
||||
|
||||
$params['file'] = $uploads['path'] . '/' . $newfilename;
|
||||
$params['url'] = $uploads['url'] . '/' . $newfilename;
|
||||
$params['type'] = 'image/jpeg';
|
||||
} else {
|
||||
unlink( $params['file'] );
|
||||
|
||||
return wp_handle_upload_error(
|
||||
$oldfilename,
|
||||
/* translators: %s: the image mime type */
|
||||
sprintf( esc_html__( 'Imsanity was unable to process the %s file. If you continue to see this error you may need to disable the conversion option in the Imsanity settings.', 'imsanity' ), $type )
|
||||
);
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/* add filters to hook into uploads */
|
||||
add_filter( 'wp_handle_upload', 'imsanity_handle_upload' );
|
||||
add_action( 'plugins_loaded', 'imsanity_init' );
|
||||
BIN
wp-content/plugins/imsanity/languages/imsanity-es_MX.mo
Normal file
BIN
wp-content/plugins/imsanity/languages/imsanity-es_MX.mo
Normal file
Binary file not shown.
223
wp-content/plugins/imsanity/languages/imsanity-es_MX.po
Normal file
223
wp-content/plugins/imsanity/languages/imsanity-es_MX.po
Normal file
@@ -0,0 +1,223 @@
|
||||
# Translation of Plugins - Imsanity - Development (trunk) in Spanish (Mexico)
|
||||
# This file is distributed under the same license as the Plugins - Imsanity - Development (trunk) package.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: 2015-12-08 16:01:42+0000\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: GlotPress/2.3.0-alpha\n"
|
||||
"Language: es_MX\n"
|
||||
"Project-Id-Version: Plugins - Imsanity - Development (trunk)\n"
|
||||
|
||||
#. Author URI of the plugin/theme
|
||||
msgid "http://verysimple.com/"
|
||||
msgstr ""
|
||||
|
||||
#. Author of the plugin/theme
|
||||
msgid "Jason Hinkle"
|
||||
msgstr ""
|
||||
|
||||
#. Description of the plugin/theme
|
||||
msgid "Imsanity stops insanely huge image uploads"
|
||||
msgstr ""
|
||||
|
||||
#. Plugin URI of the plugin/theme
|
||||
msgid "http://verysimple.com/products/imsanity/"
|
||||
msgstr ""
|
||||
|
||||
#. Plugin Name of the plugin/theme
|
||||
msgid "Imsanity"
|
||||
msgstr ""
|
||||
|
||||
#: settings.php:628
|
||||
msgid "Save Changes"
|
||||
msgstr "Guardar Cambios"
|
||||
|
||||
#: settings.php:619
|
||||
msgid "Convert PNG To JPG"
|
||||
msgstr ""
|
||||
|
||||
#: settings.php:611
|
||||
msgid "Convert BMP To JPG"
|
||||
msgstr "Convertir BMP a JPG"
|
||||
|
||||
#: settings.php:597
|
||||
msgid "JPG image quality"
|
||||
msgstr "Calidad de imagen JPG"
|
||||
|
||||
#: settings.php:556
|
||||
msgid "Imsanity settings have been configured by the server administrator. There are no site-specific settings available."
|
||||
msgstr "Configuración de Imsanity se han configurado por el administrador del servidor. No se dispone de ninguna configuración específica."
|
||||
|
||||
#: settings.php:539
|
||||
msgid "Search Images..."
|
||||
msgstr "Búsqueda de imágenes..."
|
||||
|
||||
#: settings.php:532
|
||||
msgid ""
|
||||
"It is <strong>HIGHLY</strong> recommended that you backup \n"
|
||||
"\t\tyour wp-content/uploads folder before proceeding. You will have a chance to preview and select the images to convert.\n"
|
||||
"\t\tIt is also recommended that you initially select only 1 or 2 images and verify that everything is ok before\n"
|
||||
"\t\tprocessing your entire library. You have been warned!"
|
||||
msgstr ""
|
||||
"<strong>Importante!</strong> Es recomendable que realizar el backup de carpeta wp-content/uploads \\\t\\\tyour antes de proceder. Usted tendrá la oportunidad de escuchar y seleccionar las imágenes a convertir.\n"
|
||||
"\\\t\\\tIt también se recomienda que inicialmente seleccionar sólo 1 ó 2 imágenes y comprobar que todo está bien antes de \\\t\\\tprocessing la biblioteca entera. Estáis avisados."
|
||||
|
||||
#: settings.php:530
|
||||
msgid "WARNING: BULK RESIZE WILL ALTER YOUR ORIGINAL IMAGES AND CANNOT BE UNDONE!"
|
||||
msgstr "ADVERTENCIA: A GRANEL RESIZE ALTERARÁ SUS IMÁGENES ORIGINALES Y NO SE PUEDE DESHACER!"
|
||||
|
||||
#: settings.php:519
|
||||
msgid "Bulk Resize Images"
|
||||
msgstr "A granel redimensionar imágenes"
|
||||
|
||||
#: settings.php:501
|
||||
msgid "Imsanity Settings"
|
||||
msgstr "Configuración de Imsanity"
|
||||
|
||||
#: settings.php:484
|
||||
msgid "<p>Imsanity Version %s by %s </p>"
|
||||
msgstr "<p>Imsanity versión %s de %s</p>"
|
||||
|
||||
#: settings.php:469
|
||||
msgid ""
|
||||
"<p>Imsanity automaticaly reduces the size of images that are larger than the specified maximum and replaces the original\n"
|
||||
"\t\twith one of a more \"sane\" size. Site contributors don\\'t need to concern themselves with manually scaling images\n"
|
||||
"\t\tand can upload them directly from their camera or phone.</p>\n"
|
||||
"\n"
|
||||
"\t\t<p>The resolution of modern cameras is larger than necessary for typical web display.\n"
|
||||
"\t\tThe average computer screen is not big enough to display a 3 megapixel camera-phone image at full resolution.\n"
|
||||
"\t\tWordPress does a good job of creating scaled-down copies which can be used, however the original images\n"
|
||||
"\t\tare permanently stored, taking up disk quota and, if used on a page, create a poor viewer experience.</p>\n"
|
||||
"\n"
|
||||
"\t\t<p>This plugin is designed for sites where high-resolution images are not necessary and/or site contributors\n"
|
||||
"\t\tdo not want (or understand how) to deal with scaling images. This plugin should not be used on\n"
|
||||
"\t\tsites for which original, high-resolution images must be stored.</p>\n"
|
||||
"\n"
|
||||
"\t\t<p>Be sure to save back-ups of your full-sized images if you wish to keep them.</p>"
|
||||
msgstr ""
|
||||
"<p>Imsanity reduce de forma automática el tamaño de las imágenes que son más grandes que el máximo especificado y sustituye al original\n"
|
||||
"\\\t\\\twith uno de un tamaño más\"sano\" . Colaboradores del sitio don\\'t tiene que preocuparse por la ampliación de imágenes manualmente\n"
|
||||
"\\\t\\\tand puede cargar directamente desde su cámara o teléfono . < / P>\n"
|
||||
"\n"
|
||||
"\\\t\\\t <p> La resolución de las cámaras modernas es más grande de lo necesario para la visualización web típica .\n"
|
||||
"\\\t\\pantalla media lLa no es lo suficientemente grande como para mostrar una imagen de la cámara - teléfono 3 megapíxeles con la máxima resolución .\n"
|
||||
"\\\t\\\tWordPress hace un buen trabajo de crear a escala reducida copias que se pueden utilizar , sin embargo, las imágenes originales\n"
|
||||
"\\\t\\\tara almacenado de forma permanente , tomando cuota de disco y , si se utiliza en una página, crear una experiencia pobre espectador. < / p>\n"
|
||||
"\n"
|
||||
"\\\t\\\t < p> Este plugin está diseñado para los sitios donde las imágenes de alta resolución no son necesarios y / o sitio contribuyentes\n"
|
||||
"\\\t\\\tno quieren ( o entender cómo) para hacer frente a las imágenes de escala. Este complemento no se debe utilizar en\n"
|
||||
"\\\t\\\tsites para que las imágenes originales de alta resolución deben ser almacenados . </p>\n"
|
||||
"\n"
|
||||
"\\\t\\\t <p> Asegúrese de guardar copias de seguridad de toda su imágenes de tamaño si lo desea para mantenerlos . </p>"
|
||||
|
||||
#: settings.php:467
|
||||
msgid "Imsanity automatically resizes insanely huge image uploads"
|
||||
msgstr "Automáticamente cambia el tamaño de imagen enorme subidas"
|
||||
|
||||
#: settings.php:286
|
||||
msgid "Update Settings"
|
||||
msgstr "Configuración de actualización"
|
||||
|
||||
#: settings.php:281 settings.php:607
|
||||
msgid " (WordPress default is 90)"
|
||||
msgstr " (Por defecto de WordPress es 90)"
|
||||
|
||||
#: settings.php:271
|
||||
msgid "JPG Quality"
|
||||
msgstr "Calidad JPG"
|
||||
|
||||
#: settings.php:263
|
||||
msgid "Convert PNG to JPG"
|
||||
msgstr ""
|
||||
|
||||
#: settings.php:258 settings.php:266 settings.php:614 settings.php:622
|
||||
msgid "No"
|
||||
msgstr "No"
|
||||
|
||||
#: settings.php:257 settings.php:265 settings.php:613 settings.php:621
|
||||
msgid "Yes"
|
||||
msgstr "Si"
|
||||
|
||||
#: settings.php:255
|
||||
msgid "Convert BMP to JPG"
|
||||
msgstr "Convertir BMP a JPG"
|
||||
|
||||
#: settings.php:247 settings.php:589
|
||||
msgid "Images uploaded elsewhere (Theme headers, backgrounds, logos, etc)"
|
||||
msgstr "Imágenes subidas en otros lugares (tema cabeceras, fondos, logotipos, etc.)"
|
||||
|
||||
#: settings.php:239 settings.php:582
|
||||
msgid "Images uploaded directly to the Media Library"
|
||||
msgstr "Imágenes subidas directamente a la biblioteca multimedia"
|
||||
|
||||
#: settings.php:234 settings.php:242 settings.php:250 settings.php:577
|
||||
#: settings.php:584 settings.php:591
|
||||
msgid " (or enter 0 to disable)"
|
||||
msgstr " (o escriba 0 para desactivar)"
|
||||
|
||||
#: settings.php:231 settings.php:575
|
||||
msgid "Images uploaded within a Page/Post"
|
||||
msgstr "Imágenes subidas dentro de un página y Post"
|
||||
|
||||
#: settings.php:225
|
||||
msgid "Use global Imsanity settings (below) for all sites"
|
||||
msgstr "Utilice la configuración global Imsanity (abajo) para todos los sitios"
|
||||
|
||||
#: settings.php:224
|
||||
msgid "Allow each site to configure Imsanity settings"
|
||||
msgstr "Permitir que cada sitio configurar las opciones de Imsanity"
|
||||
|
||||
#: settings.php:221
|
||||
msgid "Global Settings Override"
|
||||
msgstr "Anulación de la configuración global"
|
||||
|
||||
#: settings.php:207
|
||||
msgid "Imsanity network settings saved."
|
||||
msgstr "Configuración de red Imsanity guardado."
|
||||
|
||||
#: settings.php:187 settings.php:200
|
||||
msgid "Imsanity Network Settings"
|
||||
msgstr "Configuración de red Imsanity"
|
||||
|
||||
#: settings.php:40
|
||||
msgid "Imsanity Plugin Settings"
|
||||
msgstr "Configuración de Imsanity"
|
||||
|
||||
#: libs/imagecreatefrombmp.php:129
|
||||
msgid "imagecreatefrombmp: %s has %d bits and this is not supported!"
|
||||
msgstr "imagecreatefrombmp: %s tiene %d bits y esto no es compatible."
|
||||
|
||||
#: libs/imagecreatefrombmp.php:43
|
||||
msgid "imagecreatefrombmp: Can not obtain filesize of %s !"
|
||||
msgstr "imagecreatefrombmp: no puede obtener tamaño de %s!"
|
||||
|
||||
#: libs/imagecreatefrombmp.php:21
|
||||
msgid "imagecreatefrombmp: %s is not a bitmap!"
|
||||
msgstr "imagecreatefrombmp: %s no es un mapa de bits."
|
||||
|
||||
#: libs/imagecreatefrombmp.php:14
|
||||
msgid "imagecreatefrombmp: Can not open %s!"
|
||||
msgstr "imagecreatefrombmp: no se puede abrir %s!"
|
||||
|
||||
#: ajax.php:185
|
||||
msgid "ERROR: (Attachment with ID of %s not found) "
|
||||
msgstr "ERROR: (Adjunto con el ID de %s no encontrado) "
|
||||
|
||||
#: ajax.php:179
|
||||
msgid "SKIPPED: %s (Resize not required)"
|
||||
msgstr "OMITIDOS: %s (no es necesario redimensionar)"
|
||||
|
||||
#: ajax.php:174
|
||||
msgid "ERROR: %s (%s)"
|
||||
msgstr "ERROR: %s (%s)"
|
||||
|
||||
#: ajax.php:170
|
||||
msgid "OK: %s"
|
||||
msgstr "Bueno %s"
|
||||
|
||||
#: ajax.php:98
|
||||
msgid "Missing ID Parameter"
|
||||
msgstr "Falta el parámetro ID"
|
||||
BIN
wp-content/plugins/imsanity/languages/imsanity-sv_SE.mo
Normal file
BIN
wp-content/plugins/imsanity/languages/imsanity-sv_SE.mo
Normal file
Binary file not shown.
225
wp-content/plugins/imsanity/languages/imsanity-sv_SE.po
Normal file
225
wp-content/plugins/imsanity/languages/imsanity-sv_SE.po
Normal file
@@ -0,0 +1,225 @@
|
||||
# Translation of Plugins - Imsanity - Development (trunk) in Swedish
|
||||
# This file is distributed under the same license as the Plugins - Imsanity - Development (trunk) package.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: 2015-09-23 14:53:56+0000\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: GlotPress/2.3.0-alpha\n"
|
||||
"Language: sv_SE\n"
|
||||
"Project-Id-Version: Plugins - Imsanity - Development (trunk)\n"
|
||||
|
||||
#. Author URI of the plugin/theme
|
||||
msgid "http://verysimple.com/"
|
||||
msgstr ""
|
||||
|
||||
#. Author of the plugin/theme
|
||||
msgid "Jason Hinkle"
|
||||
msgstr ""
|
||||
|
||||
#. Description of the plugin/theme
|
||||
msgid "Imsanity stops insanely huge image uploads"
|
||||
msgstr ""
|
||||
|
||||
#. Plugin URI of the plugin/theme
|
||||
msgid "http://verysimple.com/products/imsanity/"
|
||||
msgstr ""
|
||||
|
||||
#. Plugin Name of the plugin/theme
|
||||
msgid "Imsanity"
|
||||
msgstr ""
|
||||
|
||||
#: settings.php:628
|
||||
msgid "Save Changes"
|
||||
msgstr "Spara Ändringar"
|
||||
|
||||
#: settings.php:619
|
||||
msgid "Convert PNG To JPG"
|
||||
msgstr ""
|
||||
|
||||
#: settings.php:611
|
||||
msgid "Convert BMP To JPG"
|
||||
msgstr "Konvertera BMP till JPG"
|
||||
|
||||
#: settings.php:597
|
||||
msgid "JPG image quality"
|
||||
msgstr "Bildkvalitet för JPG"
|
||||
|
||||
#: settings.php:556
|
||||
msgid "Imsanity settings have been configured by the server administrator. There are no site-specific settings available."
|
||||
msgstr "Imsanitys inställningar har konfigurerats av serveradministratören. Det finns inga webbplatsspecifika inställningar tillgängliga."
|
||||
|
||||
#: settings.php:539
|
||||
msgid "Search Images..."
|
||||
msgstr "Sök Bilder..."
|
||||
|
||||
#: settings.php:532
|
||||
msgid ""
|
||||
"It is <strong>HIGHLY</strong> recommended that you backup \n"
|
||||
"\t\tyour wp-content/uploads folder before proceeding. You will have a chance to preview and select the images to convert.\n"
|
||||
"\t\tIt is also recommended that you initially select only 1 or 2 images and verify that everything is ok before\n"
|
||||
"\t\tprocessing your entire library. You have been warned!"
|
||||
msgstr ""
|
||||
"Du rekommenderas <strong>STARKT</strong> att ta backup på \n"
|
||||
"\t\tdin wp-content/uploads mapp innan du fortsätter. Du kommer att få möjlighet att förhandsvisa och välja bilder att konvertera.\n"
|
||||
"\t\tDu rekommenderas också att först prova med 1 eller 2 bilder och kontrollera att all är ok innan\n"
|
||||
"\t\tdu processar hela mediabiblioteket. Du har blivit varnad!"
|
||||
|
||||
#: settings.php:530
|
||||
msgid "WARNING: BULK RESIZE WILL ALTER YOUR ORIGINAL IMAGES AND CANNOT BE UNDONE!"
|
||||
msgstr "VARNING: BULKSKALNING KOMMER ATT ÄNDRA ORIGINALBILDERNA OCH KAN INTE ÅNGRAS!"
|
||||
|
||||
#: settings.php:519
|
||||
msgid "Bulk Resize Images"
|
||||
msgstr "Bulkskala Bilder"
|
||||
|
||||
#: settings.php:501
|
||||
msgid "Imsanity Settings"
|
||||
msgstr "Imsanity Inställningar"
|
||||
|
||||
#: settings.php:484
|
||||
msgid "<p>Imsanity Version %s by %s </p>"
|
||||
msgstr "<p>Imsanity Version %s av %s </p>"
|
||||
|
||||
#: settings.php:469
|
||||
msgid ""
|
||||
"<p>Imsanity automaticaly reduces the size of images that are larger than the specified maximum and replaces the original\n"
|
||||
"\t\twith one of a more \"sane\" size. Site contributors don\\'t need to concern themselves with manually scaling images\n"
|
||||
"\t\tand can upload them directly from their camera or phone.</p>\n"
|
||||
"\n"
|
||||
"\t\t<p>The resolution of modern cameras is larger than necessary for typical web display.\n"
|
||||
"\t\tThe average computer screen is not big enough to display a 3 megapixel camera-phone image at full resolution.\n"
|
||||
"\t\tWordPress does a good job of creating scaled-down copies which can be used, however the original images\n"
|
||||
"\t\tare permanently stored, taking up disk quota and, if used on a page, create a poor viewer experience.</p>\n"
|
||||
"\n"
|
||||
"\t\t<p>This plugin is designed for sites where high-resolution images are not necessary and/or site contributors\n"
|
||||
"\t\tdo not want (or understand how) to deal with scaling images. This plugin should not be used on\n"
|
||||
"\t\tsites for which original, high-resolution images must be stored.</p>\n"
|
||||
"\n"
|
||||
"\t\t<p>Be sure to save back-ups of your full-sized images if you wish to keep them.</p>"
|
||||
msgstr ""
|
||||
"<p>Imsanity reducerar automatiskt storleken på bilder som är större än den specificerade maxstorleken och ersätter originalet\n"
|
||||
"\t\tmed en version som har en mer \"sund\" storlek. Webbplatsmedarbetare behöver inte bekymra sig om att manuellt skala bilder\n"
|
||||
"\t\toch kan ladda upp dem direkt från sin kamera eller mobil.</p>\n"
|
||||
"\n"
|
||||
"\t\t<p>Upplösningen på moderna kameror är högre än nödvändigt för vanlig webbvisning.\n"
|
||||
"\t\tDen genomsnittliga datorskärmen är inte stor nog att visa en 3 megapixels bild från kamera/telefon i full upplösning.\n"
|
||||
"\t\tWordPress gör ett bra jobb med att skapa nedskalade kopior som kan användas, men originalbilderna\n"
|
||||
"\t\tlagras permanent och upptar diskutrymme och skapar en dålig visuell upplevelse för besökaren om de används på en sida.</p>\n"
|
||||
"\n"
|
||||
"\t\t<p>Detta insticksprogram är designat för webbplatser där högupplösta bilder inte är nödvändiga och/eller webbplatsmedarbetare\n"
|
||||
"\t\tinte vill (eller kan) skala bilder. Detta insticksprogram bör inte användas på\n"
|
||||
"\t\twebbplatser där högupplösta bildoriginal måste lagras.</p>\n"
|
||||
"\n"
|
||||
"\t\t<p>Se till att spara kopior av dina bildoriginal i full storlek om du vill behålla dem.</p>"
|
||||
|
||||
#: settings.php:467
|
||||
msgid "Imsanity automatically resizes insanely huge image uploads"
|
||||
msgstr "Imsanity förminskar automatiskt uppladdade bilder som är galet stora"
|
||||
|
||||
#: settings.php:286
|
||||
msgid "Update Settings"
|
||||
msgstr "Uppdatera Inställningar"
|
||||
|
||||
#: settings.php:281 settings.php:607
|
||||
msgid " (WordPress default is 90)"
|
||||
msgstr " (Wordpress standardinställning är 90)"
|
||||
|
||||
#: settings.php:271
|
||||
msgid "JPG Quality"
|
||||
msgstr "JPG-kvalitet"
|
||||
|
||||
#: settings.php:263
|
||||
msgid "Convert PNG to JPG"
|
||||
msgstr ""
|
||||
|
||||
#: settings.php:258 settings.php:266 settings.php:614 settings.php:622
|
||||
msgid "No"
|
||||
msgstr "Nej"
|
||||
|
||||
#: settings.php:257 settings.php:265 settings.php:613 settings.php:621
|
||||
msgid "Yes"
|
||||
msgstr "Ja"
|
||||
|
||||
#: settings.php:255
|
||||
msgid "Convert BMP to JPG"
|
||||
msgstr "Konvertera BMP till JPG"
|
||||
|
||||
#: settings.php:247 settings.php:589
|
||||
msgid "Images uploaded elsewhere (Theme headers, backgrounds, logos, etc)"
|
||||
msgstr "Bilder uppladdade på andra ställen (Sidhuvud för teman, bakgrunder, logotyper, etc.)"
|
||||
|
||||
#: settings.php:239 settings.php:582
|
||||
msgid "Images uploaded directly to the Media Library"
|
||||
msgstr "Bilder uppladdade direkt till Mediabiblioteket"
|
||||
|
||||
#: settings.php:234 settings.php:242 settings.php:250 settings.php:577
|
||||
#: settings.php:584 settings.php:591
|
||||
msgid " (or enter 0 to disable)"
|
||||
msgstr "(eller ange 0 för att deaktivera)"
|
||||
|
||||
#: settings.php:231 settings.php:575
|
||||
msgid "Images uploaded within a Page/Post"
|
||||
msgstr "Bilder uppladdade till en Sida/Inlägg"
|
||||
|
||||
#: settings.php:225
|
||||
msgid "Use global Imsanity settings (below) for all sites"
|
||||
msgstr "Använd Imsanitys globala inställningar (nedan) för alla webbplatser"
|
||||
|
||||
#: settings.php:224
|
||||
msgid "Allow each site to configure Imsanity settings"
|
||||
msgstr "Tillåt varje webbplats att konfigurera Imsanitys inställningar"
|
||||
|
||||
#: settings.php:221
|
||||
msgid "Global Settings Override"
|
||||
msgstr "Åsidosätt Globala Inställningar"
|
||||
|
||||
#: settings.php:207
|
||||
msgid "Imsanity network settings saved."
|
||||
msgstr "Imsanity nätverksinställningar sparades."
|
||||
|
||||
#: settings.php:187 settings.php:200
|
||||
msgid "Imsanity Network Settings"
|
||||
msgstr "Imsanity Nätverksinställningar"
|
||||
|
||||
#: settings.php:40
|
||||
msgid "Imsanity Plugin Settings"
|
||||
msgstr "Imsanity Programinställningar"
|
||||
|
||||
#: libs/imagecreatefrombmp.php:129
|
||||
msgid "imagecreatefrombmp: %s has %d bits and this is not supported!"
|
||||
msgstr "imagecreatefrombmp: %s har %d bits vilket inte stöds!"
|
||||
|
||||
#: libs/imagecreatefrombmp.php:43
|
||||
msgid "imagecreatefrombmp: Can not obtain filesize of %s !"
|
||||
msgstr "imagecreatefrombmp: Kan inte hämta filstorlek %s!"
|
||||
|
||||
#: libs/imagecreatefrombmp.php:21
|
||||
msgid "imagecreatefrombmp: %s is not a bitmap!"
|
||||
msgstr "imagecreatefrombmp: %s är ingen bitmap!"
|
||||
|
||||
#: libs/imagecreatefrombmp.php:14
|
||||
msgid "imagecreatefrombmp: Can not open %s!"
|
||||
msgstr "imagecreatefrombmp: Kan inte öppna %s !"
|
||||
|
||||
#: ajax.php:185
|
||||
msgid "ERROR: (Attachment with ID of %s not found) "
|
||||
msgstr "FEL: (Bilaga med ID %s hittades ej) "
|
||||
|
||||
#: ajax.php:179
|
||||
msgid "SKIPPED: %s (Resize not required)"
|
||||
msgstr "HOPPADE ÖVER: %s (Storleksändring behövs ej)"
|
||||
|
||||
#: ajax.php:174
|
||||
msgid "ERROR: %s (%s)"
|
||||
msgstr "FEL: %s (%s)"
|
||||
|
||||
#: ajax.php:170
|
||||
msgid "OK: %s"
|
||||
msgstr "OK: %s"
|
||||
|
||||
#: ajax.php:98
|
||||
msgid "Missing ID Parameter"
|
||||
msgstr "Saknad ID-parameter"
|
||||
11
wp-content/plugins/imsanity/languages/readme.txt
Normal file
11
wp-content/plugins/imsanity/languages/readme.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
LANGUAGE TRANSLATION FILES FOR IMSANITY
|
||||
---------------------------------------
|
||||
|
||||
If you are interested in creating a language translation for Imsanity then
|
||||
you're in the right place! We would love your help, and you
|
||||
can get started translating Imsanity at https://translate.wordpress.org/projects/wp-plugins/imsanity
|
||||
|
||||
Anything you can do to help is greatly appreciated and allows
|
||||
Imsanity to be more easily used by people all over the world.
|
||||
|
||||
Thank you for supporting Imsanity and all free software!
|
||||
315
wp-content/plugins/imsanity/libs/imagecreatefrombmp.php
Normal file
315
wp-content/plugins/imsanity/libs/imagecreatefrombmp.php
Normal file
@@ -0,0 +1,315 @@
|
||||
<?php
|
||||
/**
|
||||
* The imagecreatefrombmp function converts a bmp to an image resource
|
||||
*
|
||||
* @author http://www.programmierer-forum.de/function-imagecreatefrombmp-laeuft-mit-allen-bitraten-t143137.htm
|
||||
* @package Imsanity
|
||||
*/
|
||||
|
||||
if ( ! function_exists( 'imagecreatefrombmp' ) ) {
|
||||
|
||||
/**
|
||||
* Converts a bitmap (BMP) image into an image resource.
|
||||
*
|
||||
* @param string $filename The name of the image file.
|
||||
* @return bool|object False, or a GD image resource.
|
||||
*/
|
||||
function imagecreatefrombmp( $filename ) {
|
||||
// version 1.1.
|
||||
if ( ! is_readable( $filename ) ) {
|
||||
/* translators: %s: the image filename */
|
||||
trigger_error( sprintf( __( 'imagecreatefrombmp: Can not open %s!', 'imsanity' ), $filename ), E_USER_WARNING );
|
||||
return false;
|
||||
}
|
||||
$fh = fopen( $filename, 'rb' );
|
||||
if ( ! $fh ) {
|
||||
/* translators: %s: the image filename */
|
||||
trigger_error( sprintf( __( 'imagecreatefrombmp: Can not open %s!', 'imsanity' ), $filename ), E_USER_WARNING );
|
||||
return false;
|
||||
}
|
||||
// read file header.
|
||||
$meta = unpack( 'vtype/Vfilesize/Vreserved/Voffset', fread( $fh, 14 ) );
|
||||
// check for bitmap.
|
||||
if ( 19778 !== (int) $meta['type'] ) {
|
||||
/* translators: %s: the image filename */
|
||||
trigger_error( sprintf( __( 'imagecreatefrombmp: %s is not a bitmap!', 'imsanity' ), $filename ), E_USER_WARNING );
|
||||
return false;
|
||||
}
|
||||
// read image header.
|
||||
$meta += unpack( 'Vheadersize/Vwidth/Vheight/vplanes/vbits/Vcompression/Vimagesize/Vxres/Vyres/Vcolors/Vimportant', fread( $fh, 40 ) );
|
||||
$bytes_read = 40;
|
||||
|
||||
// read additional bitfield header.
|
||||
if ( 3 === (int) $meta['compression'] ) {
|
||||
$meta += unpack( 'VrMask/VgMask/VbMask', fread( $fh, 12 ) );
|
||||
$bytes_read += 12;
|
||||
}
|
||||
|
||||
// set bytes and padding.
|
||||
$meta['bytes'] = $meta['bits'] / 8;
|
||||
$meta['decal'] = 4 - ( 4 * ( ( $meta['width'] * $meta['bytes'] / 4 ) - floor( $meta['width'] * $meta['bytes'] / 4 ) ) );
|
||||
if ( 4 === (int) $meta['decal'] ) {
|
||||
$meta['decal'] = 0;
|
||||
}
|
||||
|
||||
// obtain imagesize.
|
||||
if ( $meta['imagesize'] < 1 ) {
|
||||
$meta['imagesize'] = $meta['filesize'] - $meta['offset'];
|
||||
// in rare cases filesize is equal to offset so we need to read physical size.
|
||||
if ( $meta['imagesize'] < 1 ) {
|
||||
$meta['imagesize'] = filesize( $filename ) - $meta['offset'];
|
||||
if ( $meta['imagesize'] < 1 ) {
|
||||
/* translators: %s: the image filename */
|
||||
trigger_error( sprintf( __( 'imagecreatefrombmp: Cannot obtain filesize of %s !', 'imsanity' ), $filename ), E_USER_WARNING );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// calculate colors.
|
||||
$meta['colors'] = ! $meta['colors'] ? pow( 2, $meta['bits'] ) : $meta['colors'];
|
||||
|
||||
// read color palette.
|
||||
$palette = array();
|
||||
if ( $meta['bits'] < 16 ) {
|
||||
$palette = unpack( 'l' . $meta['colors'], fread( $fh, $meta['colors'] * 4 ) );
|
||||
// in rare cases the color value is signed.
|
||||
if ( $palette[1] < 0 ) {
|
||||
foreach ( $palette as $i => $color ) {
|
||||
$palette[ $i ] = $color + 16777216;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ignore extra bitmap headers.
|
||||
if ( $meta['headersize'] > $bytes_read ) {
|
||||
fread( $fh, $meta['headersize'] - $bytes_read );
|
||||
}
|
||||
|
||||
// create gd image.
|
||||
$im = imagecreatetruecolor( $meta['width'], $meta['height'] );
|
||||
$data = fread( $fh, $meta['imagesize'] );
|
||||
|
||||
// uncompress data.
|
||||
switch ( $meta['compression'] ) {
|
||||
case 1:
|
||||
$data = rle8_decode( $data, $meta['width'] );
|
||||
break;
|
||||
case 2:
|
||||
$data = rle4_decode( $data, $meta['width'] );
|
||||
break;
|
||||
}
|
||||
|
||||
$p = 0;
|
||||
$vide = chr( 0 );
|
||||
$y = $meta['height'] - 1;
|
||||
/* translators: %s: the image filename */
|
||||
$error = sprintf( __( 'imagecreatefrombmp: %s has not enough data!', 'imsanity' ), $filename );
|
||||
// loop through the image data beginning with the lower left corner.
|
||||
while ( $y >= 0 ) {
|
||||
$x = 0;
|
||||
while ( $x < $meta['width'] ) {
|
||||
switch ( $meta['bits'] ) {
|
||||
case 32:
|
||||
case 24:
|
||||
$part = substr( $data, $p, 3 );
|
||||
if ( ! $part ) {
|
||||
trigger_error( $error, E_USER_WARNING );
|
||||
return $im;
|
||||
}
|
||||
$color = unpack( 'V', $part . $vide );
|
||||
break;
|
||||
case 16:
|
||||
$part = substr( $data, $p, 2 );
|
||||
if ( ! $part ) {
|
||||
trigger_error( $error, E_USER_WARNING );
|
||||
return $im;
|
||||
}
|
||||
$color = unpack( 'v', $part );
|
||||
if ( empty( $meta['rMask'] ) || 0xf800 !== (int) $meta['rMask'] ) {
|
||||
$color[1] = ( ( $color[1] & 0x7c00 ) >> 7 ) * 65536 + ( ( $color[1] & 0x03e0 ) >> 2 ) * 256 + ( ( $color[1] & 0x001f ) << 3 ); // 555.
|
||||
} else {
|
||||
$color[1] = ( ( $color[1] & 0xf800 ) >> 8 ) * 65536 + ( ( $color[1] & 0x07e0 ) >> 3 ) * 256 + ( ( $color[1] & 0x001f ) << 3 ); // 565.
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
$color = unpack( 'n', $vide . substr( $data, $p, 1 ) );
|
||||
$color[1] = $palette[ $color[1] + 1 ];
|
||||
break;
|
||||
case 4:
|
||||
$color = unpack( 'n', $vide . substr( $data, floor( $p ), 1 ) );
|
||||
$color[1] = 0 === ( $p * 2 ) % 2 ? $color[1] >> 4 : $color[1] & 0x0F;
|
||||
$color[1] = $palette[ $color[1] + 1 ];
|
||||
break;
|
||||
case 1:
|
||||
$color = unpack( 'n', $vide . substr( $data, floor( $p ), 1 ) );
|
||||
switch ( ( $p * 8 ) % 8 ) {
|
||||
case 0:
|
||||
$color[1] = $color[1] >> 7;
|
||||
break;
|
||||
case 1:
|
||||
$color[1] = ( $color[1] & 0x40 ) >> 6;
|
||||
break;
|
||||
case 2:
|
||||
$color[1] = ( $color[1] & 0x20 ) >> 5;
|
||||
break;
|
||||
case 3:
|
||||
$color[1] = ( $color[1] & 0x10 ) >> 4;
|
||||
break;
|
||||
case 4:
|
||||
$color[1] = ( $color[1] & 0x8 ) >> 3;
|
||||
break;
|
||||
case 5:
|
||||
$color[1] = ( $color[1] & 0x4 ) >> 2;
|
||||
break;
|
||||
case 6:
|
||||
$color[1] = ( $color[1] & 0x2 ) >> 1;
|
||||
break;
|
||||
case 7:
|
||||
$color[1] = ( $color[1] & 0x1 );
|
||||
break;
|
||||
}
|
||||
$color[1] = $palette[ $color[1] + 1 ];
|
||||
break;
|
||||
default:
|
||||
/* translators: 1: the image filename 2: bitrate of image */
|
||||
trigger_error( sprintf( __( 'imagecreatefrombmp: %1$s has %2$d bits and this is not supported!', 'imsanity' ), $filename, $meta['bits'] ), E_USER_WARNING );
|
||||
return false;
|
||||
}
|
||||
imagesetpixel( $im, $x, $y, $color[1] );
|
||||
$x++;
|
||||
$p += $meta['bytes'];
|
||||
}
|
||||
$y--;
|
||||
$p += $meta['decal'];
|
||||
}
|
||||
fclose( $fh );
|
||||
return $im;
|
||||
}
|
||||
/**
|
||||
* The original source for these functions no longer exists, but it appears to come from
|
||||
* MSDN and has proliferated across many projects with only the stale link which now
|
||||
* points to https://docs.microsoft.com/en-us/windows/desktop/gdi/bitmap-compression.
|
||||
*/
|
||||
/**
|
||||
* Decoder for RLE8 compression in windows bitmaps.
|
||||
*
|
||||
* @param string $str Data to decode.
|
||||
* @param integer $width Image width.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function rle8_decode( $str, $width ) {
|
||||
$linewidth = $width + ( 3 - ( $width - 1 ) % 4 );
|
||||
$out = '';
|
||||
$cnt = strlen( $str );
|
||||
|
||||
for ( $i = 0; $i < $cnt; $i++ ) {
|
||||
$o = ord( $str[ $i ] );
|
||||
switch ( $o ) {
|
||||
case 0: // ESCAPE.
|
||||
$i++;
|
||||
switch ( ord( $str[ $i ] ) ) {
|
||||
case 0: // NEW LINE.
|
||||
$padcnt = $linewidth - strlen( $out ) % $linewidth;
|
||||
if ( $padcnt < $linewidth ) {
|
||||
$out .= str_repeat( chr( 0 ), $padcnt ); // pad line.
|
||||
}
|
||||
break;
|
||||
case 1: // END OF FILE.
|
||||
$padcnt = $linewidth - strlen( $out ) % $linewidth;
|
||||
if ( $padcnt < $linewidth ) {
|
||||
$out .= str_repeat( chr( 0 ), $padcnt ); // pad line.
|
||||
}
|
||||
break 3;
|
||||
case 2: // DELTA.
|
||||
$i += 2;
|
||||
break;
|
||||
default: // ABSOLUTE MODE.
|
||||
$num = ord( $str[ $i ] );
|
||||
for ( $j = 0; $j < $num; $j++ ) {
|
||||
$out .= $str[ ++$i ];
|
||||
}
|
||||
if ( $num % 2 ) {
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$out .= str_repeat( $str[ ++$i ], $o );
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decoder for RLE4 compression in windows bitmaps.
|
||||
*
|
||||
* @param string $str Data to decode.
|
||||
* @param integer $width Image width.
|
||||
* @return string
|
||||
*/
|
||||
function rle4_decode( $str, $width ) {
|
||||
$w = floor( $width / 2 ) + ( $width % 2 );
|
||||
$linewidth = $w + ( 3 - ( ( $width - 1 ) / 2 ) % 4 );
|
||||
$pixels = array();
|
||||
$cnt = strlen( $str );
|
||||
$c = 0;
|
||||
|
||||
for ( $i = 0; $i < $cnt; $i++ ) {
|
||||
$o = ord( $str[ $i ] );
|
||||
switch ( $o ) {
|
||||
case 0: // ESCAPE.
|
||||
$i++;
|
||||
switch ( ord( $str[ $i ] ) ) {
|
||||
case 0: // NEW LINE.
|
||||
while ( 0 !== count( $pixels ) % $linewidth ) {
|
||||
$pixels[] = 0;
|
||||
}
|
||||
break;
|
||||
case 1: // END OF FILE.
|
||||
while ( 0 !== count( $pixels ) % $linewidth ) {
|
||||
$pixels[] = 0;
|
||||
}
|
||||
break 3;
|
||||
case 2: // DELTA.
|
||||
$i += 2;
|
||||
break;
|
||||
default: // ABSOLUTE MODE.
|
||||
$num = ord( $str[ $i ] );
|
||||
for ( $j = 0; $j < $num; $j++ ) {
|
||||
if ( 0 === $j % 2 ) {
|
||||
$c = ord( $str[ ++$i ] );
|
||||
$pixels[] = ( $c & 240 ) >> 4;
|
||||
} else {
|
||||
$pixels[] = $c & 15;
|
||||
}
|
||||
}
|
||||
|
||||
if ( 0 === $num % 2 ) {
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$c = ord( $str[ ++$i ] );
|
||||
for ( $j = 0; $j < $o; $j++ ) {
|
||||
$pixels[] = ( 0 === $j % 2 ? ( $c & 240 ) >> 4 : $c & 15 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$out = '';
|
||||
if ( count( $pixels ) % 2 ) {
|
||||
$pixels[] = 0;
|
||||
}
|
||||
|
||||
$cnt = count( $pixels ) / 2;
|
||||
|
||||
for ( $i = 0; $i < $cnt; $i++ ) {
|
||||
$out .= chr( 16 * $pixels[ 2 * $i ] + $pixels[ 2 * $i + 1 ] );
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
181
wp-content/plugins/imsanity/libs/utils.php
Normal file
181
wp-content/plugins/imsanity/libs/utils.php
Normal file
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
/**
|
||||
* Imsanity utility functions.
|
||||
*
|
||||
* @package Imsanity
|
||||
*/
|
||||
|
||||
/**
|
||||
* Util function returns an array value, if not defined then returns default instead.
|
||||
*
|
||||
* @param array $arr Any array.
|
||||
* @param string $key Any index from that array.
|
||||
* @param mixed $default Whatever you want.
|
||||
*/
|
||||
function imsanity_val( $arr, $key, $default = '' ) {
|
||||
return isset( $arr[ $key ] ) ? $arr[ $key ] : $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the path of an attachment via the $id and the $meta.
|
||||
*
|
||||
* @param array $meta The attachment metadata.
|
||||
* @param int $id The attachment ID number.
|
||||
* @param string $file Optional. Path relative to the uploads folder. Default ''.
|
||||
* @param bool $refresh_cache Optional. True to flush cache prior to fetching path. Default true.
|
||||
* @return string The full path to the image.
|
||||
*/
|
||||
function imsanity_attachment_path( $meta, $id, $file = '', $refresh_cache = true ) {
|
||||
// Retrieve the location of the WordPress upload folder.
|
||||
$upload_dir = wp_upload_dir( null, false, $refresh_cache );
|
||||
$upload_path = trailingslashit( $upload_dir['basedir'] );
|
||||
if ( is_array( $meta ) && ! empty( $meta['file'] ) ) {
|
||||
$file_path = $meta['file'];
|
||||
if ( strpos( $file_path, 's3' ) === 0 ) {
|
||||
return '';
|
||||
}
|
||||
if ( is_file( $file_path ) ) {
|
||||
return $file_path;
|
||||
}
|
||||
$file_path = $upload_path . $file_path;
|
||||
if ( is_file( $file_path ) ) {
|
||||
return $file_path;
|
||||
}
|
||||
$upload_path = trailingslashit( WP_CONTENT_DIR ) . 'uploads/';
|
||||
$file_path = $upload_path . $meta['file'];
|
||||
if ( is_file( $file_path ) ) {
|
||||
return $file_path;
|
||||
}
|
||||
}
|
||||
if ( ! $file ) {
|
||||
$file = get_post_meta( $id, '_wp_attached_file', true );
|
||||
}
|
||||
$file_path = ( 0 !== strpos( $file, '/' ) && ! preg_match( '|^.:\\\|', $file ) ? $upload_path . $file : $file );
|
||||
$filtered_file_path = apply_filters( 'get_attached_file', $file_path, $id );
|
||||
if ( strpos( $filtered_file_path, 's3' ) === false && is_file( $filtered_file_path ) ) {
|
||||
return str_replace( '//_imsgalleries/', '/_imsgalleries/', $filtered_file_path );
|
||||
}
|
||||
if ( strpos( $file_path, 's3' ) === false && is_file( $file_path ) ) {
|
||||
return str_replace( '//_imsgalleries/', '/_imsgalleries/', $file_path );
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get mimetype based on file extension instead of file contents when speed outweighs accuracy.
|
||||
*
|
||||
* @param string $path The name of the file.
|
||||
* @return string|bool The mime type based on the extension or false.
|
||||
*/
|
||||
function imsanity_quick_mimetype( $path ) {
|
||||
$pathextension = strtolower( pathinfo( $path, PATHINFO_EXTENSION ) );
|
||||
switch ( $pathextension ) {
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
case 'jpe':
|
||||
return 'image/jpeg';
|
||||
case 'png':
|
||||
return 'image/png';
|
||||
case 'gif':
|
||||
return 'image/gif';
|
||||
case 'pdf':
|
||||
return 'application/pdf';
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the orientation/rotation of a JPG image using the EXIF data.
|
||||
*
|
||||
* @param string $file Name of the file.
|
||||
* @param string $type Mime type of the file.
|
||||
* @return int|bool The orientation value or false.
|
||||
*/
|
||||
function imsanity_get_orientation( $file, $type ) {
|
||||
if ( function_exists( 'exif_read_data' ) && 'image/jpeg' === $type ) {
|
||||
$exif = @exif_read_data( $file );
|
||||
if ( is_array( $exif ) && array_key_exists( 'Orientation', $exif ) ) {
|
||||
return (int) $exif['Orientation'];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output a fatal error and optionally die.
|
||||
*
|
||||
* @param string $message The message to output.
|
||||
* @param string $title A title/header for the message.
|
||||
* @param bool $die Default false. Whether we should die.
|
||||
*/
|
||||
function imsanity_fatal( $message, $title = '', $die = false ) {
|
||||
echo ( "<div style='margin:5px 0px 5px 0px;padding:10px;border: solid 1px red; background-color: #ff6666; color: black;'>"
|
||||
. ( $title ? "<h4 style='font-weight: bold; margin: 3px 0px 8px 0px;'>" . $title . '</h4>' : '' )
|
||||
. $message
|
||||
. '</div>' );
|
||||
if ( $die ) {
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replacement for deprecated image_resize function
|
||||
*
|
||||
* @param string $file Image file path.
|
||||
* @param int $max_w Maximum width to resize to.
|
||||
* @param int $max_h Maximum height to resize to.
|
||||
* @param bool $crop Optional. Whether to crop image or resize.
|
||||
* @param string $suffix Optional. File suffix.
|
||||
* @param string $dest_path Optional. New image file path.
|
||||
* @param int $jpeg_quality Optional, default is 90. Image quality percentage.
|
||||
* @return mixed WP_Error on failure. String with new destination path.
|
||||
*/
|
||||
function imsanity_image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 82 ) {
|
||||
if ( function_exists( 'wp_get_image_editor' ) ) {
|
||||
$editor = wp_get_image_editor( $file );
|
||||
if ( is_wp_error( $editor ) ) {
|
||||
return $editor;
|
||||
}
|
||||
$editor->set_quality( $jpeg_quality );
|
||||
|
||||
$ftype = imsanity_quick_mimetype( $file );
|
||||
|
||||
$orientation = imsanity_get_orientation( $file, $ftype );
|
||||
// Try to correct for auto-rotation if the info is available.
|
||||
switch ( $orientation ) {
|
||||
case 3:
|
||||
$editor->rotate( 180 );
|
||||
break;
|
||||
case 6:
|
||||
$editor->rotate( -90 );
|
||||
break;
|
||||
case 8:
|
||||
$editor->rotate( 90 );
|
||||
break;
|
||||
}
|
||||
|
||||
$resized = $editor->resize( $max_w, $max_h, $crop );
|
||||
if ( is_wp_error( $resized ) ) {
|
||||
return $resized;
|
||||
}
|
||||
|
||||
$dest_file = $editor->generate_filename( $suffix, $dest_path );
|
||||
|
||||
// FIX: make sure that the destination file does not exist. this fixes
|
||||
// an issue during bulk resize where one of the optimized media filenames may get
|
||||
// used as the temporary file, which causes it to be deleted.
|
||||
while ( file_exists( $dest_file ) ) {
|
||||
$dest_file = $editor->generate_filename( 'TMP', $dest_path );
|
||||
}
|
||||
|
||||
$saved = $editor->save( $dest_file );
|
||||
|
||||
if ( is_wp_error( $saved ) ) {
|
||||
return $saved;
|
||||
}
|
||||
|
||||
return $dest_file;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
782
wp-content/plugins/imsanity/license.txt
Normal file
782
wp-content/plugins/imsanity/license.txt
Normal file
@@ -0,0 +1,782 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
|
||||
Additional Copyrights
|
||||
|
||||
Portions of the software are derived from
|
||||
Licenses of included software:
|
||||
|
||||
arrive.js
|
||||
|
||||
Copyright (c) 2014-2017 Uzair Farooq
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
optipng
|
||||
|
||||
Copyright (C) 2001-2017 Cosmin Truta and the Contributing Authors.
|
||||
For the purpose of copyright and licensing, the list of Contributing
|
||||
Authors is available in the accompanying AUTHORS file.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the author(s) be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
pngquant.c
|
||||
|
||||
© 1989, 1991 by Jef Poskanzer.
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee is hereby granted, provided
|
||||
that the above copyright notice appear in all copies and that both that
|
||||
copyright notice and this permission notice appear in supporting
|
||||
documentation. This software is provided "as is" without express or
|
||||
implied warranty.
|
||||
|
||||
pngquant.c and rwpng.c/h
|
||||
|
||||
© 1997-2002 by Greg Roelofs; based on an idea by Stefan Schneider.
|
||||
© 2009-2017 by Kornel Lesiński.
|
||||
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
WebP
|
||||
|
||||
Copyright (c) 2010, Google Inc. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of Google nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
15
wp-content/plugins/imsanity/phpcs.ruleset.xml
Normal file
15
wp-content/plugins/imsanity/phpcs.ruleset.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0"?>
|
||||
<ruleset name="WordPress Coding Standards for Plugins">
|
||||
<description>Generally-applicable sniffs for WordPress plugins</description>
|
||||
|
||||
<exclude-pattern>*/vendor/*</exclude-pattern>
|
||||
<exclude-pattern>*/tests/*</exclude-pattern>
|
||||
|
||||
<rule ref="WordPress-Core" />
|
||||
<rule ref="WordPress-Docs" />
|
||||
<rule ref="WordPress.PHP.NoSilencedErrors">
|
||||
<properties>
|
||||
<property name="custom_whitelist" type="array" value="exif_read_data"/>
|
||||
</properties>
|
||||
</rule>
|
||||
</ruleset>
|
||||
160
wp-content/plugins/imsanity/readme.txt
Normal file
160
wp-content/plugins/imsanity/readme.txt
Normal file
@@ -0,0 +1,160 @@
|
||||
=== Imsanity ===
|
||||
Contributors: nosilver4u
|
||||
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MKMQKCBFFG3WW
|
||||
Tags: image, scale, resize, space saver, quality
|
||||
Requires at least: 4.9
|
||||
Tested up to: 5.2
|
||||
Requires PHP: 5.6
|
||||
Stable tag: 2.4.3
|
||||
License: GPLv3
|
||||
|
||||
Imsanity automatically resizes huge image uploads. Are contributors uploading huge photos? Tired of manually scaling? Imsanity to the rescue!
|
||||
|
||||
== Description ==
|
||||
|
||||
Imsanity automatically resizes huge image uploads down to a size that is
|
||||
more reasonable for display in browser, yet still more than large enough for typical website use.
|
||||
The plugin is configurable with a max width, height and quality. When a contributor uploads an
|
||||
image that is larger than the configured size, Imsanity will automatically scale it down to the
|
||||
configured size and replace the original image.
|
||||
|
||||
Imsanity also provides a bulk-resize feature to selectively resize previously uploaded images
|
||||
to free up disk space.
|
||||
|
||||
This plugin is ideal for blogs that do not require hi-resolution original images
|
||||
to be stored and/or the contributors don't want (or understand how) to scale images
|
||||
before uploading.
|
||||
|
||||
= Features =
|
||||
|
||||
* Automatically scales large image uploads to a more "sane" size
|
||||
* Bulk-resize feature to selectively resize existing images
|
||||
* Allows configuration of max width/height and jpg quality
|
||||
* Optionally converts BMP files to JPG so image can be scaled
|
||||
* Once enabled, Imsanity requires no actions on the part of the user
|
||||
* Uses WordPress built-in image scaling functions
|
||||
|
||||
= Translations =
|
||||
|
||||
Imsanity is available in several languages, each of which will be downloaded automatically when you install the plugin. To help translate it into your language, visit https://translate.wordpress.org/projects/wp-plugins/imsanity
|
||||
|
||||
= Contribute =
|
||||
|
||||
Imsanity is developed at https://github.com/nosilver4u/imsanity (pull requests are welcome)
|
||||
|
||||
== Installation ==
|
||||
|
||||
Automatic Installation:
|
||||
|
||||
1. Go to Admin -> Plugins -> Add New and search for "imsanity"
|
||||
2. Click the Install Button
|
||||
3. Click 'Activate'
|
||||
|
||||
Manual Installation:
|
||||
|
||||
1. Download imsanity.zip
|
||||
2. Unzip and upload the 'imsanity' folder to your '/wp-content/plugins/' directory
|
||||
3. Activate the plugin through the 'Plugins' menu in WordPress
|
||||
|
||||
== Screenshots ==
|
||||
|
||||
1. Imsanity settings page to configure max height/width
|
||||
2. Imsanity bulk image resize feature
|
||||
|
||||
== Frequently Asked Questions ==
|
||||
|
||||
= What is Imsanity? =
|
||||
|
||||
Imsanity is a plugin that automatically resizes uploaded images that are larger than the configured max width/height
|
||||
|
||||
= Will installing the Imsanity plugin alter existing images in my blog? =
|
||||
|
||||
Activating Imsanity will not alter any existing images. Imsanity resizes images as they are uploaded so
|
||||
it does not affect existing images unless you specifically use the "Bulk Image Resize" feature on
|
||||
the Imsanity settings page. The "Bulk Image Resize" feature allows you to selectively resize existing images.
|
||||
|
||||
= Why aren't all of my images detected when I try to use the bulk resize feature? =
|
||||
|
||||
Imsanity doesn't search your file system to find large files, instead it looks at the "metadata"
|
||||
in the WordPress media library database. To override this behavior, enable deep scanning.
|
||||
|
||||
= Why am I getting an error saying that my "File is not an image" ? =
|
||||
|
||||
WordPress uses the GD library to handle the image manipulation. GD can be installed and configured to support
|
||||
various types of images. If GD is not configured to handle a particular image type then you will get
|
||||
this message when you try to upload it. For more info see http://php.net/manual/en/image.installation.php
|
||||
|
||||
= How can I tell Imsanity to ignore a certain image so I can upload it without being resized? =
|
||||
|
||||
You can re-name your file and add "-noresize" to the filename. For example if your file is named
|
||||
"photo.jpg" you can rename it "photo-noresize.jpg" and Imsanity will ignore it, allowing you
|
||||
to upload the full-sized image.
|
||||
|
||||
Optionally you can temporarily adjust the max image size settings and set them to a number that is
|
||||
higher than the resolution of the image you wish to upload
|
||||
|
||||
= Why would I need this plugin? =
|
||||
|
||||
Photos taken on any modern camera and even most cellphones are too large for display full-size in a browser.
|
||||
In the case of modern DSLR cameras, the image sizes are intended for high-quality printing and are ridiculously
|
||||
over-sized for display on a web page.
|
||||
|
||||
Imsanity allows you to set a sanity limit so that all uploaded images will be constrained
|
||||
to a reasonable size which is still more than large enough for the needs of a typical website.
|
||||
Imsanity hooks into WordPress immediately after the image upload, but before WordPress processing
|
||||
occurs. So WordPress behaves exactly the same in all ways, except it will be as if the contributor
|
||||
had scaled their image to a reasonable size before uploading.
|
||||
|
||||
The size limit that imsanity uses is configurable. The default value is large enough to fill
|
||||
the average vistors entire screen without scaling so it is still more than large enough for
|
||||
typical usage.
|
||||
|
||||
= Why would I NOT want to use this plugin? =
|
||||
|
||||
You might not want to use Imsanity if you use WordPress as a stock art download
|
||||
site, provide high-res images for print or use WordPress as a high-res photo
|
||||
storage archive. If you are doing any of these things then most likely
|
||||
you already have a good understanding of image resolution.
|
||||
|
||||
= Doesn't WordPress already automatically scale images? =
|
||||
|
||||
When an image is uploaded WordPress keeps the original and, depending on the size of the original,
|
||||
will create up to 4 smaller sized copies of the file (Large, Medium-Large, Medium, Thumbnail) which are intended
|
||||
for embedding on your pages. Unless you have special photographic needs, the original usually sits
|
||||
there unused, but taking up disk quota.
|
||||
|
||||
= Why did you spell Insanity wrong? =
|
||||
|
||||
Imsanity is short for "Image Sanity Limit". A sanity limit is a term for limiting something down to
|
||||
a size or value that is reasonable.
|
||||
|
||||
= Where do I go for support? =
|
||||
|
||||
Questions may be posted on the support forum at https://wordpress.org/support/plugin/imsanity but if you don't get an answer, please use https://ewww.io/contact-us/.
|
||||
|
||||
== Changelog ==
|
||||
|
||||
= 2.4.3 =
|
||||
* changed: default size from 2048 to 1920
|
||||
* fixed: WP Import plugin breaks during Media imports
|
||||
* fixed: setting a value to 0 causes errors on multi-site
|
||||
* fixed: conversion settings not displaying correctly on multi-site
|
||||
|
||||
= 2.4.2 =
|
||||
* changed: noresize in filename also works in batch processing
|
||||
* fixed: error message does not contain filename when file is missing
|
||||
* fixed: notice on network settings when deep scan option has not been set before
|
||||
|
||||
= 2.4.1 =
|
||||
* fixed: bulk resizer scan returning incorrect results
|
||||
* fixed: sprintf error during resizing and upload
|
||||
|
||||
= 2.4.0 =
|
||||
* added: deep scanning option for when attachment metadata isn't updating properly
|
||||
* fixed: uploads from Gutenberg not detected properly
|
||||
* fixed: some other plugin(s) trying to muck with the Imsanity settings links and breaking things
|
||||
* fixed: undefined notice for query during ajax operation
|
||||
* fixed: stale metadata could prevent further resizing
|
||||
|
||||
= Earlier versions =
|
||||
Please refer to the separate changelog.txt file.
|
||||
123
wp-content/plugins/imsanity/scripts/imsanity.js
Normal file
123
wp-content/plugins/imsanity/scripts/imsanity.js
Normal file
@@ -0,0 +1,123 @@
|
||||
/**
|
||||
* imsanity admin javascript functions
|
||||
*/
|
||||
|
||||
jQuery(document).ready(function($) {$(".fade").fadeTo(5000,1).fadeOut(3000);});
|
||||
|
||||
/**
|
||||
* Begin the process of re-sizing all of the checked images
|
||||
*/
|
||||
function imsanity_resize_images()
|
||||
{
|
||||
var images = [];
|
||||
jQuery('.imsanity_image_cb:checked').each(function(i) {
|
||||
images.push(this.value);
|
||||
});
|
||||
|
||||
var target = jQuery('#resize_results');
|
||||
target.html('');
|
||||
//jQuery(document).scrollTop(target.offset().top);
|
||||
|
||||
// start the recursion
|
||||
imsanity_resize_next(images,0);
|
||||
}
|
||||
|
||||
/**
|
||||
* recursive function for resizing images
|
||||
*/
|
||||
function imsanity_resize_next(images,next_index)
|
||||
{
|
||||
if (next_index >= images.length) return imsanity_resize_complete();
|
||||
|
||||
jQuery.post(
|
||||
ajaxurl, // (defined by wordpress - points to admin-ajax.php)
|
||||
{_wpnonce: imsanity_vars._wpnonce, action: 'imsanity_resize_image', id: images[next_index]},
|
||||
function(response)
|
||||
{
|
||||
var result;
|
||||
var target = jQuery('#resize_results');
|
||||
target.show();
|
||||
|
||||
try {
|
||||
result = JSON.parse(response);
|
||||
target.append('<div>' + (next_index+1) + '/' + images.length + ' >> ' + result['message'] +'</div>');
|
||||
}
|
||||
catch(e) {
|
||||
target.append('<div>' + imsanity_vars.invalid_response + '</div>');
|
||||
if (console) {
|
||||
console.warn(images[next_index] + ': '+ e.message);
|
||||
console.warn('Invalid JSON Response: ' + response);
|
||||
}
|
||||
}
|
||||
|
||||
target.animate({scrollTop: target.prop('scrollHeight')}, 200);
|
||||
// recurse
|
||||
imsanity_resize_next(images,next_index+1);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* fired when all images have been resized
|
||||
*/
|
||||
function imsanity_resize_complete()
|
||||
{
|
||||
var target = jQuery('#resize_results');
|
||||
target.append('<div><strong>' + imsanity_vars.resizing_complete + '</strong></div>');
|
||||
target.animate({scrollTop: target.prop('scrollHeight')});
|
||||
}
|
||||
|
||||
/**
|
||||
* ajax post to return all images that are candidates for resizing
|
||||
* @param string the id of the html element into which results will be appended
|
||||
*/
|
||||
function imsanity_load_images(container_id)
|
||||
{
|
||||
var container = jQuery('#'+container_id);
|
||||
|
||||
var target = jQuery('#imsanity_target');
|
||||
target.show();
|
||||
jQuery('.imsanity-selection').remove();
|
||||
jQuery('#imsanity_loading').show();
|
||||
|
||||
target.animate({height: [250,'swing']},500, function()
|
||||
{
|
||||
jQuery(document).scrollTop(container.offset().top);
|
||||
|
||||
jQuery.post(
|
||||
ajaxurl, // (global defined by wordpress - points to admin-ajax.php)
|
||||
{_wpnonce: imsanity_vars._wpnonce, action: 'imsanity_get_images'},
|
||||
function(response) {
|
||||
var is_json = true;
|
||||
try {
|
||||
var images = jQuery.parseJSON(response);
|
||||
} catch ( err ) {
|
||||
is_json = false;
|
||||
}
|
||||
if ( ! is_json ) {
|
||||
console.log( response );
|
||||
return false;
|
||||
}
|
||||
|
||||
jQuery('#imsanity_loading').hide();
|
||||
if (images.length > 0)
|
||||
{
|
||||
target.append('<div class="imsanity-selection"><input id="imsanity_check_all" type="checkbox" checked="checked" onclick="jQuery(\'.imsanity_image_cb\').attr(\'checked\', this.checked);" /> Select All</div>');
|
||||
for (var i = 0; i < images.length; i++)
|
||||
{
|
||||
target.append('<div class="imsanity-selection"><input class="imsanity_image_cb" name="imsanity_images" value="' + images[i].id + '" type="checkbox" checked="checked" />' + imsanity_vars.image + ' ' + images[i].id + ': ' + images[i].file +' ('+images[i].width+' x '+images[i].height+')</div>');
|
||||
}
|
||||
if ( ! jQuery( '#resize-submit' ).length ) {
|
||||
container.append('<p id="resize-submit" class="submit"><button class="button-primary" onclick="imsanity_resize_images();">' + imsanity_vars.resize_selected + '</button></p>');
|
||||
container.append('<div id="resize_results" style="display: none; border: solid 2px #666666; padding: 10px; height: 250px; overflow: auto;" />');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
target.html('<div>' + imsanity_vars.none_found + '</div>');
|
||||
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
601
wp-content/plugins/imsanity/settings.php
Normal file
601
wp-content/plugins/imsanity/settings.php
Normal file
@@ -0,0 +1,601 @@
|
||||
<?php
|
||||
/**
|
||||
* Imsanity settings and admin UI.
|
||||
*
|
||||
* @package Imsanity
|
||||
*/
|
||||
|
||||
// Setup custom $wpdb attribute for our image-tracking table.
|
||||
global $wpdb;
|
||||
if ( ! isset( $wpdb->imsanity_ms ) ) {
|
||||
$wpdb->imsanity_ms = $wpdb->get_blog_prefix( 0 ) . 'imsanity';
|
||||
}
|
||||
|
||||
// Register the plugin settings menu.
|
||||
add_action( 'admin_menu', 'imsanity_create_menu' );
|
||||
add_action( 'network_admin_menu', 'imsanity_register_network' );
|
||||
add_filter( 'plugin_action_links_imsanity/imsanity.php', 'imsanity_settings_link' );
|
||||
add_action( 'admin_enqueue_scripts', 'imsanity_queue_script' );
|
||||
add_action( 'admin_init', 'imsanity_register_settings' );
|
||||
|
||||
register_activation_hook( 'imsanity/imsanity.php', 'imsanity_maybe_created_custom_table' );
|
||||
|
||||
// settings cache.
|
||||
$_imsanity_multisite_settings = null;
|
||||
|
||||
/**
|
||||
* Create the settings menu item in the WordPress admin navigation and
|
||||
* link it to the plugin settings page
|
||||
*/
|
||||
function imsanity_create_menu() {
|
||||
// Create new menu for site configuration.
|
||||
add_options_page( esc_html__( 'Imsanity Plugin Settings', 'imsanity' ), 'Imsanity', 'administrator', __FILE__, 'imsanity_settings_page' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the network settings page
|
||||
*/
|
||||
function imsanity_register_network() {
|
||||
if ( ! function_exists( 'is_plugin_active_for_network' ) && is_multisite() ) {
|
||||
// Need to include the plugin library for the is_plugin_active function.
|
||||
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
||||
}
|
||||
if ( is_multisite() && is_plugin_active_for_network( 'imsanity/imsanity.php' ) ) {
|
||||
add_submenu_page( 'settings.php', esc_html__( 'Imsanity Network Settings', 'imsanity' ), 'Imsanity', 'manage_options', 'imsanity_network', 'imsanity_network_settings' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings link that appears on the plugins overview page
|
||||
*
|
||||
* @param array $links The plugin action links.
|
||||
* @return array The action links, with a settings link pre-pended.
|
||||
*/
|
||||
function imsanity_settings_link( $links ) {
|
||||
if ( ! is_array( $links ) ) {
|
||||
$links = array();
|
||||
}
|
||||
$settings_link = '<a href="' . get_admin_url( null, 'options-general.php?page=' . __FILE__ ) . '">' . esc_html__( 'Settings', 'imsanity' ) . '</a>';
|
||||
array_unshift( $links, $settings_link );
|
||||
return $links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Queues up the AJAX script and any localized JS vars we need.
|
||||
*
|
||||
* @param string $hook The hook name for the current page.
|
||||
*/
|
||||
function imsanity_queue_script( $hook ) {
|
||||
// Make sure we are being called from the settings page.
|
||||
if ( strpos( $hook, 'settings_page_imsanity' ) !== 0 ) {
|
||||
return;
|
||||
}
|
||||
// Register the scripts that are used by the bulk resizer.
|
||||
wp_enqueue_script( 'imsanity_script', plugins_url( '/scripts/imsanity.js', __FILE__ ), array( 'jquery' ), IMSANITY_VERSION );
|
||||
wp_localize_script(
|
||||
'imsanity_script',
|
||||
'imsanity_vars',
|
||||
array(
|
||||
'_wpnonce' => wp_create_nonce( 'imsanity-bulk' ),
|
||||
'resizing_complete' => esc_html__( 'Resizing Complete', 'imsanity' ),
|
||||
'resize_selected' => esc_html__( 'Resize Selected Images', 'imsanity' ),
|
||||
'image' => esc_html__( 'Image', 'imsanity' ),
|
||||
'invalid_response' => esc_html__( 'Received an invalid response, please check for errors in the Developer Tools console of your browser.', 'imsanity' ),
|
||||
'none_found' => esc_html__( 'There are no images that need to be resized.', 'imsanity' ),
|
||||
)
|
||||
);
|
||||
add_action( 'admin_print_styles', 'imsanity_settings_css' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the multi-site settings table exists
|
||||
*
|
||||
* @return bool True if the Imsanity table exists.
|
||||
*/
|
||||
function imsanity_multisite_table_exists() {
|
||||
global $wpdb;
|
||||
return $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->imsanity_ms'" ) === $wpdb->imsanity_ms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the schema version for the Imsanity table.
|
||||
*
|
||||
* @return string The version identifier for the schema.
|
||||
*/
|
||||
function imsanity_multisite_table_schema_version() {
|
||||
// If the table doesn't exist then there is no schema to report.
|
||||
if ( ! imsanity_multisite_table_exists() ) {
|
||||
return '0';
|
||||
}
|
||||
|
||||
global $wpdb;
|
||||
$version = $wpdb->get_var( "SELECT data FROM $wpdb->imsanity_ms WHERE setting = 'schema'" );
|
||||
|
||||
if ( ! $version ) {
|
||||
$version = '1.0'; // This is a legacy version 1.0 installation.
|
||||
}
|
||||
|
||||
return $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default network settings in the case where they are not
|
||||
* defined in the database, or multi-site is not enabled.
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
function imsanity_get_default_multisite_settings() {
|
||||
$data = new stdClass();
|
||||
|
||||
$data->imsanity_override_site = false;
|
||||
$data->imsanity_max_height = IMSANITY_DEFAULT_MAX_HEIGHT;
|
||||
$data->imsanity_max_width = IMSANITY_DEFAULT_MAX_WIDTH;
|
||||
$data->imsanity_max_height_library = IMSANITY_DEFAULT_MAX_HEIGHT;
|
||||
$data->imsanity_max_width_library = IMSANITY_DEFAULT_MAX_WIDTH;
|
||||
$data->imsanity_max_height_other = IMSANITY_DEFAULT_MAX_HEIGHT;
|
||||
$data->imsanity_max_width_other = IMSANITY_DEFAULT_MAX_WIDTH;
|
||||
$data->imsanity_bmp_to_jpg = IMSANITY_DEFAULT_BMP_TO_JPG;
|
||||
$data->imsanity_png_to_jpg = IMSANITY_DEFAULT_PNG_TO_JPG;
|
||||
$data->imsanity_deep_scan = false;
|
||||
$data->imsanity_quality = IMSANITY_DEFAULT_QUALITY;
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* On activation create the multisite database table if necessary. this is
|
||||
* called when the plugin is activated as well as when it is automatically
|
||||
* updated.
|
||||
*/
|
||||
function imsanity_maybe_created_custom_table() {
|
||||
// If not a multi-site no need to do any custom table lookups.
|
||||
if ( ! function_exists( 'is_multisite' ) || ( ! is_multisite() ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$schema = imsanity_multisite_table_schema_version();
|
||||
|
||||
if ( '0' === $schema ) {
|
||||
// This is an initial database setup.
|
||||
$sql = 'CREATE TABLE IF NOT EXISTS ' . $wpdb->imsanity_ms . ' (
|
||||
setting varchar(55),
|
||||
data text NOT NULL,
|
||||
PRIMARY KEY (setting)
|
||||
);';
|
||||
|
||||
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
||||
dbDelta( $sql );
|
||||
|
||||
// Add the rows to the database.
|
||||
$data = imsanity_get_default_multisite_settings();
|
||||
$wpdb->insert(
|
||||
$wpdb->imsanity_ms,
|
||||
array(
|
||||
'setting' => 'multisite',
|
||||
'data' => maybe_serialize( $data ),
|
||||
)
|
||||
);
|
||||
$wpdb->insert(
|
||||
$wpdb->imsanity_ms,
|
||||
array(
|
||||
'setting' => 'schema',
|
||||
'data' => IMSANITY_SCHEMA_VERSION,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( IMSANITY_SCHEMA_VERSION !== $schema ) {
|
||||
// This is a schema update. for the moment there is only one schema update available, from 1.0 to 1.1.
|
||||
if ( '1.0' === $schema ) {
|
||||
// Update from version 1.0 to 1.1.
|
||||
$wpdb->insert(
|
||||
$wpdb->imsanity_ms,
|
||||
array(
|
||||
'setting' => 'schema',
|
||||
'data' => IMSANITY_SCHEMA_VERSION,
|
||||
)
|
||||
);
|
||||
$wpdb->query( "ALTER TABLE $wpdb->imsanity_ms CHANGE COLUMN data data TEXT NOT NULL;" );
|
||||
} else {
|
||||
// @todo we don't have this yet
|
||||
$wpdb->update(
|
||||
$wpdb->imsanity_ms,
|
||||
array( 'data' => IMSANITY_SCHEMA_VERSION ),
|
||||
array( 'setting' => 'schema' )
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the form for the multi-site settings page.
|
||||
*/
|
||||
function imsanity_network_settings() {
|
||||
$settings = imsanity_get_multisite_settings(); ?>
|
||||
<div class="wrap">
|
||||
<h1><?php esc_html_e( 'Imsanity Network Settings', 'imsanity' ); ?></h1>
|
||||
|
||||
<form method="post" action="settings.php?page=imsanity_network">
|
||||
<input type="hidden" name="update_imsanity_settings" value="1" />
|
||||
<?php wp_nonce_field( 'imsanity_network_options' ); ?>
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th scope="row"><label for="imsanity_override_site"><?php esc_html_e( 'Global Settings Override', 'imsanity' ); ?></label></th>
|
||||
<td>
|
||||
<select name="imsanity_override_site">
|
||||
<option value="0" <?php selected( $settings->imsanity_override_site, '0' ); ?> ><?php esc_html_e( 'Allow each site to configure Imsanity settings', 'imsanity' ); ?></option>
|
||||
<option value="1" <?php selected( $settings->imsanity_override_site, '1' ); ?> ><?php esc_html_e( 'Use global Imsanity settings (below) for all sites', 'imsanity' ); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row"><?php esc_html_e( 'Images uploaded within a Page/Post', 'imsanity' ); ?></th>
|
||||
<td>
|
||||
<label for="imsanity_max_width"><?php esc_html_e( 'Max Width', 'imsanity' ); ?></label> <input type="number" step="1" min="0" class='small-text' name="imsanity_max_width" value="<?php echo (int) $settings->imsanity_max_width; ?>" />
|
||||
<label for="imsanity_max_height"><?php esc_html_e( 'Max Height', 'imsanity' ); ?></label> <input type="number" step="1" min="0" class="small-text" name="imsanity_max_height" value="<?php echo (int) $settings->imsanity_max_height; ?>" /> <?php esc_html_e( 'in pixels, enter 0 to disable', 'imsanity' ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row"><?php esc_html_e( 'Images uploaded directly to the Media Library', 'imsanity' ); ?></th>
|
||||
<td>
|
||||
<label for="imsanity_max_width_library"><?php esc_html_e( 'Max Width', 'imsanity' ); ?></label> <input type="number" step="1" min="0" class='small-text' name="imsanity_max_width_library" value="<?php echo (int) $settings->imsanity_max_width_library; ?>" />
|
||||
<label for="imsanity_max_height_library"><?php esc_html_e( 'Max Height', 'imsanity' ); ?></label> <input type="number" step="1" min="0" class="small-text" name="imsanity_max_height_library" value="<?php echo (int) $settings->imsanity_max_height_library; ?>" /> <?php esc_html_e( 'in pixels, enter 0 to disable', 'imsanity' ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row"><?php esc_html_e( 'Images uploaded elsewhere (Theme headers, backgrounds, logos, etc)', 'imsanity' ); ?></th>
|
||||
<td>
|
||||
<label for="imsanity_max_width_other"><?php esc_html_e( 'Max Width', 'imsanity' ); ?></label> <input type="number" step="1" min="0" class='small-text' name="imsanity_max_width_other" value="<?php echo (int) $settings->imsanity_max_width_other; ?>" />
|
||||
<label for="imsanity_max_height_other"><?php esc_html_e( 'Max Height', 'imsanity' ); ?></label> <input type="number" step="1" min="0" class="small-text" name="imsanity_max_height_other" value="<?php echo (int) $settings->imsanity_max_height_other; ?>" /> <?php esc_html_e( 'in pixels, enter 0 to disable', 'imsanity' ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row"><label for"imsanity_bmp_to_jpg"><?php esc_html_e( 'Convert BMP to JPG', 'imsanity' ); ?></label></th>
|
||||
<td><select name="imsanity_bmp_to_jpg">
|
||||
<option value="1" <?php selected( $settings->imsanity_bmp_to_jpg, '1' ); ?> ><?php esc_html_e( 'Yes', 'imsanity' ); ?></option>
|
||||
<option value="0" <?php selected( $settings->imsanity_bmp_to_jpg, '0' ); ?> ><?php esc_html_e( 'No', 'imsanity' ); ?></option>
|
||||
</select></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row"><label for="imsanity_png_to_jpg"><?php esc_html_e( 'Convert PNG to JPG', 'imsanity' ); ?></label></th>
|
||||
<td><select name="imsanity_png_to_jpg">
|
||||
<option value="1" <?php selected( $settings->imsanity_png_to_jpg, '1' ); ?> ><?php esc_html_e( 'Yes', 'imsanity' ); ?></option>
|
||||
<option value="0" <?php selected( $settings->imsanity_png_to_jpg, '0' ); ?> ><?php esc_html_e( 'No', 'imsanity' ); ?></option>
|
||||
</select></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row"><label for='imsanity_quality' ><?php esc_html_e( 'JPG image quality', 'imsanity' ); ?></th>
|
||||
<td><input type='text' id='imsanity_quality' name='imsanity_quality' class='small-text' value='<?php echo (int) $settings->imsanity_quality; ?>' /> <?php esc_html_e( 'Valid values are 1-100.', 'imsanity' ); ?>
|
||||
<p class='description'><?php esc_html_e( 'WordPress default is 82', 'imsanity' ); ?></p></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row"><label for="imsanity_deep_scan"><?php esc_html_e( 'Deep Scan', 'imsanity' ); ?></label></th>
|
||||
<td><input type="checkbox" id="imsanity_deep_scan" name="imsanity_deep_scan" value="true"<?php echo ( $settings->imsanity_deep_scan ) ? " checked='true'" : ''; ?> /><?php esc_html_e( 'If searching repeatedly returns the same images, deep scanning will check the actual image dimensions instead of relying on metadata from the database.', 'imsanity' ); ?></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<p class="submit"><input type="submit" class="button-primary" value="<?php esc_attr_e( 'Update Settings', 'imsanity' ); ?>" /></p>
|
||||
|
||||
</form>
|
||||
<?php
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the form, update the network settings
|
||||
* and clear the cached settings
|
||||
*/
|
||||
function imsanity_network_settings_update() {
|
||||
if ( ! current_user_can( 'manage_options' ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'imsanity_network_options' ) ) {
|
||||
return;
|
||||
}
|
||||
global $wpdb;
|
||||
global $_imsanity_multisite_settings;
|
||||
|
||||
// ensure that the custom table is created when the user updates network settings
|
||||
// this is not ideal but it's better than checking for this table existance
|
||||
// on every page load.
|
||||
imsanity_maybe_created_custom_table();
|
||||
|
||||
$data = new stdClass();
|
||||
|
||||
$data->imsanity_override_site = (bool) $_POST['imsanity_override_site'];
|
||||
$data->imsanity_max_height = sanitize_text_field( $_POST['imsanity_max_height'] );
|
||||
$data->imsanity_max_width = sanitize_text_field( $_POST['imsanity_max_width'] );
|
||||
$data->imsanity_max_height_library = sanitize_text_field( $_POST['imsanity_max_height_library'] );
|
||||
$data->imsanity_max_width_library = sanitize_text_field( $_POST['imsanity_max_width_library'] );
|
||||
$data->imsanity_max_height_other = sanitize_text_field( $_POST['imsanity_max_height_other'] );
|
||||
$data->imsanity_max_width_other = sanitize_text_field( $_POST['imsanity_max_width_other'] );
|
||||
$data->imsanity_bmp_to_jpg = (bool) $_POST['imsanity_bmp_to_jpg'];
|
||||
$data->imsanity_png_to_jpg = (bool) $_POST['imsanity_png_to_jpg'];
|
||||
$data->imsanity_quality = imsanity_jpg_quality( $_POST['imsanity_quality'] );
|
||||
$data->imsanity_deep_scan = empty( $_POST['imsanity_deep_scan'] ) ? 0 : 1;
|
||||
|
||||
$success = $wpdb->update(
|
||||
$wpdb->imsanity_ms,
|
||||
array( 'data' => maybe_serialize( $data ) ),
|
||||
array( 'setting' => 'multisite' )
|
||||
);
|
||||
|
||||
// Clear the cache.
|
||||
$_imsanity_multisite_settings = null;
|
||||
add_action( 'network_admin_notices', 'imsanity_network_settings_saved' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a message to inform the user the multi-site setting have been saved.
|
||||
*/
|
||||
function imsanity_network_settings_saved() {
|
||||
echo "<div id='imsanity-network-settings-saved' class='updated fade'><p><strong>" . esc_html__( 'Imsanity network settings saved.', 'imsanity' ) . '</strong></p></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the multi-site settings as a standard class. If the settings are not
|
||||
* defined in the database or multi-site is not enabled then the default settings
|
||||
* are returned. This is cached so it only loads once per page load, unless
|
||||
* imsanity_network_settings_update is called.
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
function imsanity_get_multisite_settings() {
|
||||
global $_imsanity_multisite_settings;
|
||||
$result = null;
|
||||
|
||||
if ( ! $_imsanity_multisite_settings ) {
|
||||
if ( function_exists( 'is_multisite' ) && is_multisite() ) {
|
||||
global $wpdb;
|
||||
$result = $wpdb->get_var( "SELECT data FROM $wpdb->imsanity_ms WHERE setting = 'multisite'" );
|
||||
}
|
||||
|
||||
// if there's no results, return the defaults instead.
|
||||
$_imsanity_multisite_settings = $result
|
||||
? unserialize( $result )
|
||||
: imsanity_get_default_multisite_settings();
|
||||
|
||||
// this is for backwards compatibility.
|
||||
if ( ! isset( $_imsanity_multisite_settings->imsanity_max_height_library ) ) {
|
||||
$_imsanity_multisite_settings->imsanity_max_height_library = $_imsanity_multisite_settings->imsanity_max_height;
|
||||
$_imsanity_multisite_settings->imsanity_max_width_library = $_imsanity_multisite_settings->imsanity_max_width;
|
||||
$_imsanity_multisite_settings->imsanity_max_height_other = $_imsanity_multisite_settings->imsanity_max_height;
|
||||
$_imsanity_multisite_settings->imsanity_max_width_other = $_imsanity_multisite_settings->imsanity_max_width;
|
||||
}
|
||||
$_imsanity_multisite_settings->imsanity_override_site = ! empty( $_imsanity_multisite_settings->imsanity_override_site ) ? '1' : '0';
|
||||
$_imsanity_multisite_settings->imsanity_bmp_to_jpg = ! empty( $_imsanity_multisite_settings->imsanity_bmp_to_jpg ) ? '1' : '0';
|
||||
$_imsanity_multisite_settings->imsanity_png_to_jpg = ! empty( $_imsanity_multisite_settings->imsanity_png_to_jpg ) ? '1' : '0';
|
||||
if ( ! property_exists( $_imsanity_multisite_settings, 'imsanity_deep_scan' ) ) {
|
||||
$_imsanity_multisite_settings->imsanity_deep_scan = false;
|
||||
}
|
||||
}
|
||||
return $_imsanity_multisite_settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the option setting for the given key, first checking to see if it has been
|
||||
* set globally for multi-site. Otherwise checking the site options.
|
||||
*
|
||||
* @param string $key The name of the option to retrieve.
|
||||
* @param string $ifnull Value to use if the requested option returns null.
|
||||
*/
|
||||
function imsanity_get_option( $key, $ifnull ) {
|
||||
$result = null;
|
||||
|
||||
$settings = imsanity_get_multisite_settings();
|
||||
|
||||
if ( $settings->imsanity_override_site ) {
|
||||
$result = $settings->$key;
|
||||
if ( is_null( $result ) ) {
|
||||
$result = $ifnull;
|
||||
}
|
||||
} else {
|
||||
$result = get_option( $key, $ifnull );
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the configuration settings that the plugin will use
|
||||
*/
|
||||
function imsanity_register_settings() {
|
||||
if ( ! function_exists( 'is_plugin_active_for_network' ) && is_multisite() ) {
|
||||
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
||||
}
|
||||
// We only want to update if the form has been submitted.
|
||||
if ( isset( $_POST['update_imsanity_settings'] ) && is_multisite() && is_plugin_active_for_network( 'imsanity/imsanity.php' ) ) {
|
||||
imsanity_network_settings_update();
|
||||
}
|
||||
// Register our settings.
|
||||
register_setting( 'imsanity-settings-group', 'imsanity_max_height' );
|
||||
register_setting( 'imsanity-settings-group', 'imsanity_max_width' );
|
||||
register_setting( 'imsanity-settings-group', 'imsanity_max_height_library' );
|
||||
register_setting( 'imsanity-settings-group', 'imsanity_max_width_library' );
|
||||
register_setting( 'imsanity-settings-group', 'imsanity_max_height_other' );
|
||||
register_setting( 'imsanity-settings-group', 'imsanity_max_width_other' );
|
||||
register_setting( 'imsanity-settings-group', 'imsanity_bmp_to_jpg' );
|
||||
register_setting( 'imsanity-settings-group', 'imsanity_png_to_jpg' );
|
||||
register_setting( 'imsanity-settings-group', 'imsanity_quality', 'imsanity_jpg_quality' );
|
||||
register_setting( 'imsanity-settings-group', 'imsanity_deep_scan' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate and return the JPG quality setting.
|
||||
*
|
||||
* @param int $quality The JPG quality currently set.
|
||||
* @return int The (potentially) adjusted quality level.
|
||||
*/
|
||||
function imsanity_jpg_quality( $quality = null ) {
|
||||
if ( is_null( $quality ) ) {
|
||||
$quality = get_option( 'imsanity_quality' );
|
||||
}
|
||||
if ( preg_match( '/^(100|[1-9][0-9]?)$/', $quality ) ) {
|
||||
return (int) $quality;
|
||||
} else {
|
||||
return IMSANITY_DEFAULT_QUALITY;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to render css styles for the settings forms
|
||||
* for both site and network settings page
|
||||
*/
|
||||
function imsanity_settings_css() {
|
||||
echo '
|
||||
<style>
|
||||
#imsanity_header {
|
||||
border: solid 1px #c6c6c6;
|
||||
margin: 10px 0px;
|
||||
padding: 0px 10px;
|
||||
background-color: #e1e1e1;
|
||||
}
|
||||
#imsanity_header p {
|
||||
margin: .5em 0;
|
||||
}
|
||||
</style>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the settings page by writing directly to stdout. if multi-site is enabled
|
||||
* and imsanity_override_site is true, then display a notice message that settings
|
||||
* are not editable instead of the settings form
|
||||
*/
|
||||
function imsanity_settings_page() {
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h1><?php esc_html_e( 'Imsanity Settings', 'imsanity' ); ?></h1>
|
||||
<?php
|
||||
|
||||
$settings = imsanity_get_multisite_settings();
|
||||
|
||||
if ( $settings->imsanity_override_site ) {
|
||||
imsanity_settings_page_notice();
|
||||
} else {
|
||||
imsanity_settings_page_form();
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<h2 style="margin-top: 0px;"><?php esc_html_e( 'Bulk Resize Images', 'imsanity' ); ?></h2>
|
||||
|
||||
<div id="imsanity_header">
|
||||
<p><?php esc_html_e( 'If you have existing images that were uploaded prior to installing Imsanity, you may resize them all in bulk to recover disk space. To begin, click the "Search Images" button to search all existing attachments for images that are larger than the configured limit.', 'imsanity' ); ?></p>
|
||||
<?php /* translators: %d: the number of images */ ?>
|
||||
<p><?php printf( esc_html__( 'NOTE: To give you greater control over the resizing process, a maximum of %d images will be returned at one time. Bitmap images cannot be bulk resized and will not appear in the search results.', 'imsanity' ), IMSANITY_AJAX_MAX_RECORDS ); ?></p>
|
||||
</div>
|
||||
|
||||
<div style="border: solid 1px #ff6666; background-color: #ffbbbb; padding: 0 10px;">
|
||||
<h4><?php esc_html_e( 'WARNING: Bulk Resize will alter your original images and cannot be undone!', 'imsanity' ); ?></h4>
|
||||
|
||||
<p><?php esc_html_e( 'It is HIGHLY recommended that you backup your wp-content/uploads folder before proceeding. You will have a chance to preview and select the images to convert.', 'imsanity' ); ?><br>
|
||||
<?php esc_html_e( 'It is also recommended that you initially select only 1 or 2 images and verify that everything is working properly before processing your entire library.', 'imsanity' ); ?></p>
|
||||
</div>
|
||||
|
||||
<p class="submit" id="imsanity-examine-button">
|
||||
<button class="button-primary" onclick="imsanity_load_images('imsanity_image_list');"><?php esc_html_e( 'Search Images...', 'imsanity' ); ?></button>
|
||||
</p>
|
||||
<div id='imsanity_image_list'>
|
||||
<div id="imsanity_target" style="display: none; border: solid 2px #666666; padding: 10px; height: 0px; overflow: auto;">
|
||||
<div id="imsanity_loading" style="display: none;"><img src="<?php echo plugins_url( 'images/ajax-loader.gif', __FILE__ ); ?>" style="margin-bottom: .25em; vertical-align:middle;" />
|
||||
<?php esc_html_e( 'Scanning existing images. This may take a moment.', 'imsanity' ); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Multi-user config file exists so display a notice
|
||||
*/
|
||||
function imsanity_settings_page_notice() {
|
||||
?>
|
||||
<div class="updated settings-error">
|
||||
<p><strong><?php esc_html_e( 'Imsanity settings have been configured by the server administrator. There are no site-specific settings available.', 'imsanity' ); ?></strong></p>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the site settings form. This is processed by
|
||||
* WordPress built-in options persistance mechanism
|
||||
*/
|
||||
function imsanity_settings_page_form() {
|
||||
?>
|
||||
<form method="post" action="options.php">
|
||||
<?php settings_fields( 'imsanity-settings-group' ); ?>
|
||||
<table class="form-table">
|
||||
|
||||
<tr>
|
||||
<th scope="row"><?php esc_html_e( 'Images uploaded within a Page/Post', 'imsanity' ); ?></th>
|
||||
<td>
|
||||
<label for="imsanity_max_width"><?php esc_html_e( 'Max Width', 'imsanity' ); ?></label> <input type="number" step="1" min="0" class="small-text" name="imsanity_max_width" value="<?php echo (int) get_option( 'imsanity_max_width', IMSANITY_DEFAULT_MAX_WIDTH ); ?>" />
|
||||
<label for="imsanity_max_height"><?php esc_html_e( 'Max Height', 'imsanity' ); ?></label> <input type="number" step="1" min="0" class="small-text" name="imsanity_max_height" value="<?php echo (int) get_option( 'imsanity_max_height', IMSANITY_DEFAULT_MAX_HEIGHT ); ?>" /> <?php esc_html_e( 'in pixels, enter 0 to disable', 'imsanity' ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row"><?php esc_html_e( 'Images uploaded directly to the Media Library', 'imsanity' ); ?></th>
|
||||
<td>
|
||||
<label for="imsanity_max_width_library"><?php esc_html_e( 'Max Width', 'imsanity' ); ?></label> <input type="number" step="1" min="0" class="small-text" name="imsanity_max_width_library" value="<?php echo (int) get_option( 'imsanity_max_width_library', IMSANITY_DEFAULT_MAX_WIDTH ); ?>" />
|
||||
<label for="imsanity_max_height_library"><?php esc_html_e( 'Max Height', 'imsanity' ); ?></label> <input type="number" step="1" min="0" class="small-text" name="imsanity_max_height_library" value="<?php echo (int) get_option( 'imsanity_max_height_library', IMSANITY_DEFAULT_MAX_HEIGHT ); ?>" /> <?php esc_html_e( 'in pixels, enter 0 to disable', 'imsanity' ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row"><?php esc_html_e( 'Images uploaded elsewhere (Theme headers, backgrounds, logos, etc)', 'imsanity' ); ?></th>
|
||||
<td>
|
||||
<label for="imsanity_max_width_other"><?php esc_html_e( 'Max Width', 'imsanity' ); ?></label> <input type="number" step="1" min="0" class="small-text" name="imsanity_max_width_other" value="<?php echo (int) get_option( 'imsanity_max_width_other', IMSANITY_DEFAULT_MAX_WIDTH ); ?>" />
|
||||
<label for="imsanity_max_height_other"><?php esc_html_e( 'Max Height', 'imsanity' ); ?></label> <input type="number" step="1" min="0" class="small-text" name="imsanity_max_height_other" value="<?php echo (int) get_option( 'imsanity_max_height_other', IMSANITY_DEFAULT_MAX_HEIGHT ); ?>" /> <?php esc_html_e( 'in pixels, enter 0 to disable', 'imsanity' ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<th scope="row"><label for='imsanity_quality' ><?php esc_html_e( 'JPG image quality', 'imsanity' ); ?></th>
|
||||
<td><input type='text' id='imsanity_quality' name='imsanity_quality' class='small-text' value='<?php echo imsanity_jpg_quality(); ?>' /> <?php esc_html_e( 'Valid values are 1-100.', 'imsanity' ); ?>
|
||||
<p class='description'><?php esc_html_e( 'WordPress default is 82', 'imsanity' ); ?></p></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row"><label for="imsanity_bmp_to_jpg"><?php esc_html_e( 'Convert BMP To JPG', 'imsanity' ); ?></label></th>
|
||||
<td><select name="imsanity_bmp_to_jpg">
|
||||
<option <?php selected( get_option( 'imsanity_bmp_to_jpg', IMSANITY_DEFAULT_BMP_TO_JPG ), '1' ); ?> value="1"><?php esc_html_e( 'Yes', 'imsanity' ); ?></option>
|
||||
<option <?php selected( get_option( 'imsanity_bmp_to_jpg', IMSANITY_DEFAULT_BMP_TO_JPG ), '0' ); ?> value="0"><?php esc_html_e( 'No', 'imsanity' ); ?></option>
|
||||
</select></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row"><label for="imsanity_png_to_jpg"><?php esc_html_e( 'Convert PNG To JPG', 'imsanity' ); ?></label></th>
|
||||
<td><select name="imsanity_png_to_jpg">
|
||||
<option <?php selected( get_option( 'imsanity_png_to_jpg', IMSANITY_DEFAULT_PNG_TO_JPG ), '1' ); ?> value="1"><?php esc_html_e( 'Yes', 'imsanity' ); ?></option>
|
||||
<option <?php selected( get_option( 'imsanity_png_to_jpg', IMSANITY_DEFAULT_PNG_TO_JPG ), '0' ); ?> value="0"><?php esc_html_e( 'No', 'imsanity' ); ?></option>
|
||||
</select></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row"><label for="imsanity_deep_scan"><?php esc_html_e( 'Deep Scan', 'imsanity' ); ?></label></th>
|
||||
<td><input type="checkbox" id="imsanity_deep_scan" name="imsanity_deep_scan" value="true"<?php echo ( get_option( 'imsanity_deep_scan' ) ) ? " checked='true'" : ''; ?> /><?php esc_html_e( 'If searching repeatedly returns the same images, deep scanning will check the actual image dimensions instead of relying on metadata from the database.', 'imsanity' ); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p class="submit"><input type="submit" class="button-primary" value="<?php esc_attr_e( 'Save Changes', 'imsanity' ); ?>" /></p>
|
||||
|
||||
</form>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user