Changeset 2451318
- Timestamp:
- 01/06/2021 02:14:54 PM (5 years ago)
- Location:
- wp-image-sizes
- Files:
-
- 14 added
- 3 edited
-
tags/1.1.2 (added)
-
tags/1.1.2/assets (added)
-
tags/1.1.2/assets/css (added)
-
tags/1.1.2/assets/css/wpis-style.css (added)
-
tags/1.1.2/assets/js (added)
-
tags/1.1.2/assets/js/api-request.min.js (added)
-
tags/1.1.2/assets/js/wpis.js (added)
-
tags/1.1.2/includes (added)
-
tags/1.1.2/includes/tab-templates (added)
-
tags/1.1.2/includes/tab-templates/image-sizes.php (added)
-
tags/1.1.2/includes/wpis-settings.php (added)
-
tags/1.1.2/readme.txt (added)
-
tags/1.1.2/wp-image-sizes.php (added)
-
tags/1.1.2/wpis-init.php (added)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/wp-image-sizes.php (modified) (1 diff)
-
trunk/wpis-init.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wp-image-sizes/trunk/readme.txt
r2450551 r2451318 4 4 Requires at least: 4.7 5 5 Requires PHP: 5.2.4 6 Stable tag: 1.1. 16 Stable tag: 1.1.2 7 7 Tested up to: 5.6 8 8 License: GPLv2 or later … … 66 66 67 67 == Changelog == 68 = 1.1.2 = 69 * Compatibility fix with pro version when generating runtime images 68 70 = 1.1.1 = 69 71 * Code changes for compatibility with pro version -
wp-image-sizes/trunk/wp-image-sizes.php
r2450551 r2451318 4 4 * Plugin URI: https://aiwatech.com/wp-image-sizes 5 5 * Description: Save server space by creating selected image sizes for every post type. It allows to select registered image sizes in media uploader and helps to avoid creation of unneccessary images. 6 * Version: 1.1. 16 * Version: 1.1.2 7 7 * Requires at least: 4.7 8 8 * Tested up to: 5.6 -
wp-image-sizes/trunk/wpis-init.php
r2450551 r2451318 24 24 endif; 25 25 26 27 if(!function_exists("wpis_get_attachment_image_src")):28 //=== Create Images on Runtime ===//29 add_filter( "wp_get_attachment_image_src", "wpis_get_attachment_image_src", 10, 4 );30 function wpis_get_attachment_image_src( $image, $attachment_id, $size, $icon ){31 global $wpis_settings;32 33 if( is_admin() ){34 return $image;35 }36 37 if( $wpis_settings["runtime_image_sizes"] == "Yes" ){38 39 if( $image && $size != "full" ){40 41 $wp_upload_dir = wp_upload_dir();42 $attachment = get_post( $attachment_id );43 $mime_type = get_post_mime_type( $attachment );44 //$original_path = wp_get_original_image_path( $attachment_id );45 $original_path = get_attached_file( $attachment_id );46 $image_meta = wp_get_attachment_metadata( $attachment_id );47 48 $attachement_dir = dirname( $image_meta["file"] );49 50 $image_name = pathinfo( $image_meta["file"], PATHINFO_FILENAME );51 $image_basename = pathinfo( $image_meta["file"], PATHINFO_BASENAME );52 $image_extension= pathinfo( $image_meta["file"], PATHINFO_EXTENSION );53 54 switch ( gettype( $size ) ) {55 case "string":56 $image_sizes = wp_get_additional_image_sizes();57 58 $width = $image_sizes[$size]["width"];59 $height = $image_sizes[$size]["height"];60 61 break;62 63 case "array":64 $width = $size[0];65 $height = $size[1];66 67 break;68 }69 70 if( !$width && !$height ){71 return $image;72 }73 74 $new_name = wp_sprintf("%s-%dx%d.%s", $image_name, intval($width), intval($height), $image_extension);75 $image_path = $wp_upload_dir["basedir"] . DIRECTORY_SEPARATOR . $attachement_dir . DIRECTORY_SEPARATOR . $new_name;76 $image_url = $wp_upload_dir["baseurl"] . "/". $attachement_dir . "/". $new_name;77 78 if( !file_exists($image_path) ){79 80 $image_editor = wp_get_image_editor( $original_path );81 82 if ( ! is_wp_error( $image_editor ) ) {83 84 $image_editor->resize( $width, $height, $image_sizes[$size]["crop"] );85 $image_editor->save( $image_path );86 87 $image_dimensions = $image_editor->get_size();88 $image[0] = $image_url;89 $image[1] = $image_dimensions["width"];90 $image[2] = $image_dimensions["height"];91 }92 93 }else{94 $image[0] = $image_url;95 }96 97 //=== If array is passed as image size98 if( gettype($size) == "array" ){99 $size = wp_sprintf("%s_%s", $width, $height);100 }101 102 $image_meta["sizes"][$size]["file"] = $new_name;103 $image_meta["sizes"][$size]["width"] = $width;104 $image_meta["sizes"][$size]["height"] = $height;105 $image_meta["sizes"][$size]["mime-type"]= $mime_type;106 107 wp_update_attachment_metadata( $attachment_id, $image_meta );108 109 }110 }111 112 return $image;113 }114 endif;115 26 116 27 if(!function_exists("wpis_image_sizes_advanced")):
Note: See TracChangeset
for help on using the changeset viewer.