Changeset 1754829
- Timestamp:
- 10/29/2017 06:25:24 PM (8 years ago)
- Location:
- resize-images-in-posts/trunk
- Files:
-
- 3 edited
-
includes/image-resize.php (modified) (9 diffs)
-
readme.txt (modified) (2 diffs)
-
resize-images-in-posts.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
resize-images-in-posts/trunk/includes/image-resize.php
r1576551 r1754829 11 11 $defaults = array( 12 12 'thumbnail_url' => '', 13 'thumbnail_post_id' => '', 13 14 'thumbnail_id' => '', 14 15 'thumbnail_width' => 0, … … 16 17 'thumbnail_crop' => false, 17 18 'thumbnail_quality' => 90, 18 'thumbnail_resize_gif' => true 19 'thumbnail_resize_gif' => true, 20 'thumbnail_download_external_site' => false 19 21 ); 20 22 … … 23 25 // If we have no thumbnail_url value 24 26 if ( empty( $instance['thumbnail_url'] ) ) { 25 $thumbnail_url = get_post_meta( get_the_ID(), 'image', true ); 27 if ( ! empty( $instance['thumbnail_post_id'] ) ) { 28 $post_id = $instance['thumbnail_post_id']; 29 } else { 30 $post_id = get_the_ID(); 31 } 32 33 $thumbnail_url = get_post_meta( $post_id, 'image', true ); 26 34 27 35 if ( ! empty( $thumbnail_url ) ) { 28 36 $instance['thumbnail_url'] = $thumbnail_url; 29 37 } else { 30 $instance['thumbnail_id'] = get_post_thumbnail_id(); 38 if ( empty( $instance['thumbnail_id'] ) ) { 39 $instance['thumbnail_id'] = get_post_thumbnail_id( $post_id ); 40 } 31 41 } 32 42 } … … 39 49 40 50 if ( ! empty( $instance['thumbnail_url'] ) ) { 41 42 // Image located into uploads folder43 51 $return = resize_images_in_posts__dynamically_image_resize_base( $instance ); 44 52 } … … 87 95 $crop_in_url .= '-c'; 88 96 89 if ( ! ( (string) $x == 'center' and (string) $y == 'center' ) ) {97 if ( ! ( (string) $x == 'center' and (string) $y == 'center' ) ) { 90 98 $crop_in_url .= '-' . (string) $x . '-' . (string) $y; 91 99 } … … 128 136 129 137 if ( ! file_exists( $image_file_resized ) ) { 138 130 139 if ( file_exists( $image_file ) and function_exists( 'getimagesize' ) ) { 131 140 $original_image_sizes = @getimagesize( $image_file ); … … 135 144 $orig_h = $original_image_sizes[1]; 136 145 137 // If the original width and height are smaller than desired width and height 146 // If the original width and height are smaller than desired width and height we don't want to resize it 138 147 if ( ( (int) $instance['thumbnail_width'] >= (int) $orig_w and (int) $instance['thumbnail_height'] >= (int) $orig_h ) or ( (int) $instance['thumbnail_width'] == 0 and (int) $instance['thumbnail_height'] == 0 ) ) { 139 $additional_info_url = '';140 141 148 $image_resize_dimensions = true; 142 149 143 150 $new_w = $orig_w; 144 151 $new_h = $orig_h; 152 153 $additional_info_url = ''; 145 154 } else { 146 155 $image_resize_dimensions = image_resize_dimensions( (int) $orig_w, (int) $orig_h, (int) $instance['thumbnail_width'], (int) $instance['thumbnail_height'], $instance['thumbnail_crop'] ); 147 156 148 $new_w = $image_resize_dimensions[4]; 149 $new_h = $image_resize_dimensions[5]; 150 151 $additional_info_url = '-' . (int) $new_w . 'x' . (int) $new_h . $crop_in_url; 157 // if the resulting image would be the same size or larger we don't want to resize it 158 if ( $image_resize_dimensions === false ) { 159 $image_resize_dimensions = true; 160 161 $new_w = $orig_w; 162 $new_h = $orig_h; 163 164 $additional_info_url = ''; 165 } else { 166 $new_w = $image_resize_dimensions[4]; 167 $new_h = $image_resize_dimensions[5]; 168 169 $additional_info_url = '-' . (int) $new_w . 'x' . (int) $new_h . $crop_in_url; 170 } 152 171 } 153 172 … … 168 187 $image->save( $image_file_resized ); 169 188 170 $res ize_images_in_posts__image = array(189 $result_image = array( 171 190 'url' => $image_url_resized, 172 191 'width' => (int) $new_w, 173 192 'height' => (int) $new_h, 174 193 'crop' => $instance['thumbnail_crop'], 175 'original_url' => $url_decoded, 176 'is_local_file' => true 194 'original_url' => $url_decoded 177 195 ); 178 196 179 $return = $res ize_images_in_posts__image;197 $return = $result_image; 180 198 } 181 199 } else { 182 200 183 $res ize_images_in_posts__image = array(201 $result_image = array( 184 202 'url' => $image_url_resized, 185 203 'width' => (int) $new_w, 186 204 'height' => (int) $new_h, 187 205 'crop' => $instance['thumbnail_crop'], 188 'original_url' => $url_decoded, 189 'is_local_file' => true 206 'original_url' => $url_decoded 190 207 ); 191 208 192 $return = $res ize_images_in_posts__image;209 $return = $result_image; 193 210 } 194 211 } … … 196 213 } 197 214 } else { 198 $res ize_images_in_posts__image = array(215 $result_image = array( 199 216 'url' => $image_url_resized, 200 217 'width' => (int) $instance['thumbnail_width'], 201 218 'height' => (int) $instance['thumbnail_height'], 202 219 'crop' => $instance['thumbnail_crop'], 203 'original_url' => $url_decoded, 204 'is_local_file' => true 220 'original_url' => $url_decoded 205 221 ); 206 222 207 $return = $res ize_images_in_posts__image;223 $return = $result_image; 208 224 } 209 225 } -
resize-images-in-posts/trunk/readme.txt
r1597477 r1754829 12 12 13 13 == Description == 14 15 This is a WordPress plugin. 14 16 15 17 If you want to resize images in your posts automatically so the page will load faster and use less bandwidth then this plugin can help you. … … 61 63 == Changelog == 62 64 65 = 4.3 = 66 * Updated a little image resize function 67 63 68 = 4.2 = 64 69 * Fix site info value -
resize-images-in-posts/trunk/resize-images-in-posts.php
r1597477 r1754829 44 44 /** Versions **********************************************************/ 45 45 46 $this->version = '4. 2';46 $this->version = '4.3'; 47 47 48 48 // Setup some base path and URL information
Note: See TracChangeset
for help on using the changeset viewer.