Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#38965 closed defect (bug) (fixed)

Thumbnails with dimensions lower than the thumbnail setting aren't recognized

Reported by: Clorith Owned by: joemcgill
Priority: normal Milestone: 4.7
Component: Media Version: 4.7
Severity: normal Keywords: has-patch has-unit-tests commit dev-reviewed
Cc: Focuses:

Description

If an image is uploaded with a width and height lower than those defined in Settings > media, the thumbnail size won't be defined, and the default "file" icon is shown in grid view (in list view it will show a version of the thumbnail).

This goes both for the media listing, as well as the add media modal.

This is a regression from 4.6, as thumbnails for smaller images are generated as expected on 4.6.1

As reported by @leemon in ​https://wordpress.org/support/topic/no-thumbnails-in-the-grid-view-of-the-media-library/

Attachments (2)

38965.diff​ (587 bytes ) - added by joemcgill 10 years ago.
38965.2.diff​ (1.5 KB ) - added by joemcgill 10 years ago.

Download all attachments as: .zip

Change History (12)

#1 @joemcgill
10 years ago

  • Owner set to joemcgill
  • Status new → reviewing

@joemcgill
10 years ago

#2 @joemcgill
10 years ago

  • Keywords has-patch needs-unit-tests added
  • Milestone Awaiting Review → 4.7
  • Status reviewing → accepted

Turns out the issue is related to a change to wp_prepare_attachment_for_js() introduced in [38949], which results in a sizes attribute not being generated if there are no intermediate sizes in the metadata. Specifically, it's the change to this line:

Old:
if ( $meta && 'image' === $type ) {

New:
if ( $meta && ! empty( $meta['sizes'] ) ) {

38965.diff​ addresses the issue by always adding a sizes attribute when the attachment type is an image.

#3 @kirasong
10 years ago

Just to make sure it makes its way back here from Slack, +1 for commit of this patch, but holding off on adding the tag because @joemcgill noted he'd like it to go in with a unit test change (which is a good idea here).

Current tests pass.

@joemcgill
10 years ago

#4 @joemcgill
10 years ago

  • Keywords has-unit-tests added; needs-unit-tests removed

38965.2.diff​ adds a unit test.

This ticket was mentioned in ​Slack in #core-media by joemcgill. ​View the logs.


10 years ago

This ticket was mentioned in ​Slack in #core by helen. ​View the logs.


10 years ago

#7 @joemcgill
10 years ago

  • Keywords commit added

#8 @kirasong
10 years ago

  • Keywords dev-reviewed added

+1.

Working on a commit per conversation in Slack.

#9 @kirasong
10 years ago

  • Resolution → fixed
  • Status accepted → closed

In 39396:

Media: Fix regression with display of small images in media library.

Fixes a regression in the media library after [38949], which caused
small images (< thumbnail size) to not display within the media library.

Accounts for images that have no intermediate sizes
in wp_prepare_attachment_for_js().

Adds test.

Fixes #38965.
Props joemcgill, clorith, mikeschroder.

#10 @kirasong
10 years ago

In 39399:

Media: Fix regression with display of small images in media library.

Fixes a regression in the media library after [38949], which caused
small images (< thumbnail size) to not display within the media library.

Accounts for images that have no intermediate sizes
in wp_prepare_attachment_for_js().

Adds test.

Merges [39396] to the 4.7 branch.

Fixes #38965 for 4.7.
Props joemcgill, clorith, mikeschroder.

Note: See TracTickets for help on using tickets.