From e0c4e4c8048b4f83344badc9a46c698583ccd593 Mon Sep 17 00:00:00 2001 From: Ben Huson Date: Wed, 1 Feb 2017 21:29:41 +0000 Subject: [PATCH 1/3] Bump minimum WordPress version to 3.5 --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index f89c306..2694076 100644 --- a/readme.txt +++ b/readme.txt @@ -2,7 +2,7 @@ Contributors: mfields, husobj, jamiemchale Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QSYTTQZBRKQVE Tags: taxonomy, tag, category, term, image, upload, media -Requires at least: 3.4 +Requires at least: 3.5 Tested up to: 4.5 Stable tag: 0.9.6 License: GPLv2 or later From 81927e42f3eae8257d8dc4eaf4aee44d492871f6 Mon Sep 17 00:00:00 2001 From: Ben Huson Date: Wed, 1 Feb 2017 22:03:17 +0000 Subject: [PATCH 2/3] Remove use of deprecated `image_resize` function. --- taxonomy-images.php | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/taxonomy-images.php b/taxonomy-images.php index bfa8f48..1b04a40 100644 --- a/taxonomy-images.php +++ b/taxonomy-images.php @@ -160,31 +160,47 @@ function taxonomy_image_plugin_get_image_src( $id ) { return $img['url']; } - /* Detail image does not exist, attempt to create it. */ + // Detail image does not exist, attempt to create it. $wp_upload_dir = wp_upload_dir(); + if ( isset( $wp_upload_dir['basedir'] ) ) { /* Create path to original uploaded image. */ $path = trailingslashit( $wp_upload_dir['basedir'] ) . get_post_meta( $id, '_wp_attached_file', true ); if ( is_file( $path ) ) { - /* Attempt to create a new downsized version of the original image. */ - $new = image_resize( $path, - $detail['size'][0], - $detail['size'][1], - $detail['size'][2] - ); + // Attempt to create a new downsized version of the original image + $new = wp_get_image_editor( $path ); - /* Image creation successful. Generate and cache image metadata. Return url. */ + // Image editor instance OK if ( ! is_wp_error( $new ) ) { - $meta = wp_generate_attachment_metadata( $id, $path ); - wp_update_attachment_metadata( $id, $meta ); - $img = image_get_intermediate_size( $id, $detail['name'] ); - if ( isset( $img['url'] ) ) { - return $img['url']; + + $resized = $new->resize( + $detail['size'][0], + $detail['size'][1], + absint( $detail['size'][2] ) + ); + + // Image resize successful. Generate and cache image metadata. Return url. + if ( ! is_wp_error( $resized ) ) { + + $path = $new->generate_filename(); + $new->save( $path ); + + $meta = wp_generate_attachment_metadata( $id, $path ); + wp_update_attachment_metadata( $id, $meta ); + $img = image_get_intermediate_size( $id, $detail['name'] ); + + if ( isset( $img['url'] ) ) { + return $img['url']; + } + } + } + } + } /* Custom intermediate size cannot be created, try for thumbnail. */ From bd47e6b81383d8f7c74727a96acf7500da296179 Mon Sep 17 00:00:00 2001 From: Ben Huson Date: Thu, 16 Feb 2017 07:41:40 +0000 Subject: [PATCH 3/3] Version 0.9.7 --- CHANGELOG.md | 9 ++++++++- README.md | 3 +++ readme.txt | 11 +++++++++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f6e3fc..d5da895 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## [0.9.7] - 2017-02-16 + +### Changed +- Remove use of deprecated `image_resize` function. +- Bump minimum WordPress version to 3.5. + ## [0.9.6] - 2016-05-03 ### Fixed @@ -208,7 +214,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Added - Original Release - Works with WordPress 2.9.1. -[Unreleased]: https://github.com/benhuson/Taxonomy-Images/compare/0.9.6...HEAD +[Unreleased]: https://github.com/benhuson/Taxonomy-Images/compare/0.9.7...HEAD +[0.9.7]: https://github.com/benhuson/Taxonomy-Images/compare/0.9.6...0.9.7 [0.9.6]: https://github.com/benhuson/Taxonomy-Images/compare/0.9.5...0.9.6 [0.9.5]: https://github.com/benhuson/Taxonomy-Images/compare/0.9.4...0.9.5 [0.9.4]: https://github.com/benhuson/Taxonomy-Images/compare/0.9.3...0.9.4 diff --git a/README.md b/README.md index 426fe5f..a7db6f7 100644 --- a/README.md +++ b/README.md @@ -221,6 +221,9 @@ Installation Upgrade Notice -------------- +### 0.9.7 +Remove use of deprecated `image_resize` function. Bump minimum WordPress version to 3.5. + ### 0.9.6 Fixed issue where if no terms have images but 'having_images' is false, nothing would be returned (props Matt). diff --git a/readme.txt b/readme.txt index 2694076..f44dd69 100644 --- a/readme.txt +++ b/readme.txt @@ -3,8 +3,8 @@ Contributors: mfields, husobj, jamiemchale Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QSYTTQZBRKQVE Tags: taxonomy, tag, category, term, image, upload, media Requires at least: 3.5 -Tested up to: 4.5 -Stable tag: 0.9.6 +Tested up to: 4.7.2 +Stable tag: 0.9.7 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -209,6 +209,9 @@ The original author of this plugin, Michael Fields, released a handful of plugin == Upgrade Notice == += 0.9.7 = +Remove use of deprecated `image_resize` function. Bump minimum WordPress version to 3.5. + = 0.9.6 = Fixed issue where if no terms have images but 'having_images' is false, nothing would be returned (props Matt). @@ -238,6 +241,10 @@ Complete rewrite. Better everything. Many bug fixes. == Changelog == += 0.9.7 = +* __UPDATE:__ Remove use of deprecated `image_resize` function. +* __UPDATE:__ Bump minimum WordPress version to 3.5. + = 0.9.6 = * __BUGFIX:__ Fix issue where if no terms have images but 'having_images' is false, nothing would be returned (props Matt).