Skip to content

Select the smaller image size from the list of available sources#233

Closed
jjgrainger wants to merge 2 commits into
trunkfrom
feature/186-select-smaller-image-size-from-sources
Closed

Select the smaller image size from the list of available sources#233
jjgrainger wants to merge 2 commits into
trunkfrom
feature/186-select-smaller-image-size-from-sources

Conversation

@jjgrainger
Copy link
Copy Markdown
Contributor

Summary

Fixes #186 Select the smaller image size from the list of available sources

Relevant technical choices

Checklist

  • PR has either [Focus] or Infrastructure label.
  • PR has a [Type] label.
  • PR has a milestone or the no milestone label.

@jjgrainger jjgrainger requested a review from mitogh March 17, 2022 17:14
@jjgrainger jjgrainger added [Type] Enhancement A suggestion for improvement of an existing feature [Focus] Images [Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) labels Mar 17, 2022
}

// Return the resized image sources.
if ( isset( $metadata['sizes'][ $size ]['sources'] ) && ! empty( $metadata['sizes'][ $size ]['sources'] ) ) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case empty works simiarly to isset so you can avoid the isset call.

Suggested change
if ( isset( $metadata['sizes'][ $size ]['sources'] ) && ! empty( $metadata['sizes'][ $size ]['sources'] ) ) {
if ( ! empty( $metadata['sizes'][ $size ]['sources'] ) ) {

}

// Return an empty array if no sources found.
return [];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using the long syntax array for arrays due to WP styleguide.

Suggested change
return [];
return array();

@jjgrainger
Copy link
Copy Markdown
Contributor Author

Thanks @mitogh

As you suggested I've created a new PR that branches from other work this expands on.

I've addressed the feedback in the new PR #243

Closing this.

@jjgrainger jjgrainger closed this Mar 21, 2022
@jjgrainger jjgrainger deleted the feature/186-select-smaller-image-size-from-sources branch March 21, 2022 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Plugin] Modern Image Formats Issues for the Modern Image Formats plugin (formerly WebP Uploads) [Type] Enhancement A suggestion for improvement of an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Select the smaller image size from the list of available sources

2 participants