WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 4 months ago

#17262 new enhancement

wp_get_attachment_thumb_file should check new 'thumbnail' image size

Reported by: lonnylot Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.0
Component: Media Keywords: needs-patch needs-unit-tests
Focuses: Cc:

Description (last modified by DrewAPicture)

The issue is that on line 3863 we always search for $imagedata['thumb'] and it never exists. Instead we have $imagedata['thumbnail']. This always exists.

Attachments (4)

post.diff (302 bytes) - added by lonnylot 4 years ago.
17262.diff (597 bytes) - added by lonnylot 4 years ago.
wp-includes/post.php diff
17262.2.diff (1.0 KB) - added by wonderboymusic 3 years ago.
post.2.diff (726 bytes) - added by JoshuaAbenazer 2 years ago.
This one first checks for the "fall back to the old thumbnail" and if that returns false then goes ahead and checks according to the revised array

Download all attachments as: .zip

Change History (22)

@lonnylot4 years ago

comment:1 @scribu4 years ago

  • Keywords has-patch removed

Please submit patches as svn diffs. Tutorials can be found on the trac homepage.

Last edited 4 years ago by scribu (previous) (diff)

@lonnylot4 years ago

wp-includes/post.php diff

comment:2 @lonnylot4 years ago

Sorry for the delay! Added the correct diff off of trunk rev. 18191

comment:3 @nacin4 years ago

  • Version changed from 3.2 to 3.0

So does wp_get_attachment_thumb_file() ever work? That function should probably be deprecated in favor of the various other functions now.

comment:4 @lonnylot4 years ago

As far as I can tell not unless you add a custom image type called 'thumb'

comment:5 @azaozz4 years ago

@nacin is right, deprecate +1.

comment:6 @scribu4 years ago

  • Keywords needs-patch 3.3-early added
  • Milestone changed from Awaiting Review to Future Release

comment:7 @tw21133 years ago

  • Cc michael.d.beckwith@… added

@wonderboymusic3 years ago

comment:8 @wonderboymusic3 years ago

  • Keywords has-patch added; needs-patch removed
  • Milestone changed from Future Release to 3.6

17262.2.diff updates wp_get_attachment_thumb_file() so it works in trunk. The previous patch did not have current code in mind. It's not immediately obvious to me what wp_get_attachment_thumb_file() and wp_get_attachment_thumb_url() would be deprecated in favor of.

comment:9 @nacin2 years ago

'thumb' is the old-style thumbnail, prior to proper intermediate sizes ('thumbnail' / 'medium' / 'large').

wp_get_attachment_thumb_url() does return the newer 'thumbnail' if it exists, and falls back to wp_get_attachment_thumb_file() if it does not.

You can see a bit of code history in image_downsize(): "fall back to the old thumbnail" in a code comment.

Not sure what _file() should return in a deprecated situation. _url() is basically the old-school form of wp_get_attachment_image_src( $size = 'thumbnail' ), which returns array( $src, $width, $height ). Which is kind of lame.

So, perhaps they can both be updated to work on 'thumbnail', and then left, as wp_get_attachment_thumb_url() is definitely easier, nicer, and more obvious to use than wp_get_attachment_image_src()['url'], and according to MarkJaquith, is widely used by plugins (probably for that reason).

Last edited 2 years ago by SergeyBiryukov (previous) (diff)

comment:10 @SergeyBiryukov2 years ago

#23556 was marked as a duplicate.

@JoshuaAbenazer2 years ago

This one first checks for the "fall back to the old thumbnail" and if that returns false then goes ahead and checks according to the revised array

comment:11 @SergeyBiryukov2 years ago

#10492 was marked as a duplicate.

comment:12 @DrewAPicture2 years ago

  • Description modified (diff)

comment:13 @nacin2 years ago

  • Keywords 3.7-early added; 3.3-early removed
  • Milestone changed from 3.6 to Future Release
  • Summary changed from wp_get_attachment_thumb_file is always false to wp_get_attachment_thumb_file should check new 'thumbnail' image size
  • Type changed from defect (bug) to enhancement

Let's clean this up and get it going for 3.7.

comment:14 @wonderboymusic2 years ago

  • Milestone changed from Future Release to 3.7

comment:15 @wonderboymusic2 years ago

these are all marked 3.7-early

comment:16 @nacin22 months ago

  • Keywords needs-patch needs-unit-tests added; 3.7-early has-patch removed
  • Milestone changed from 3.7 to Future Release

post.2.diff is still a bit messy, and could use unit tests.

comment:17 @ircbot16 months ago

This ticket was mentioned in IRC in #wordpress-dev by SergeyBiryukov. View the logs.

comment:18 in reply to: ↑ description @jevuska4 months ago

Replying to lonnylot:

The issue is that on line 3863 we always search for $imagedata['thumb'] and it never exists. Instead we have $imagedata['thumbnail']. This always exists.

Nothing change in 4.2 beta. Just found this solving at https://wordpress.org/support/topic/fix-for-bug-in-wp_get_attachment_thumb_file-1

Note: See TracTickets for help on using tickets.