Skip to content

Commit

Permalink
Merge branch 'release/0.9.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
benhuson committed Feb 16, 2017
2 parents 71e325a + bd47e6b commit 89311fc
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 17 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
13 changes: 10 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
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
Tested up to: 4.5
Stable tag: 0.9.6
Requires at least: 3.5
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

Expand Down Expand Up @@ -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).

Expand Down Expand Up @@ -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).

Expand Down
42 changes: 29 additions & 13 deletions taxonomy-images.php
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down

0 comments on commit 89311fc

Please sign in to comment.