WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#12146 closed defect (bug) (fixed)

Post thumbnails should not be affected by $content_width

Reported by: Viper007Bond Owned by:
Milestone: 3.0 Priority: normal
Severity: normal Version: 3.0
Component: Post Thumbnails Keywords: has-patch needs-testing
Focuses: Cc:

Description

set_post_thumbnail_size( 940, 198, true );
$content_width = 640;
the_post_thumbnail();

Outputs something like this:

<img width="640" height="134" src=".../filename-940x198.png" class="attachment-post-thumbnail wp-post-image" alt="" title="title" />

Note that the thumbnail is being generated correctly, but the HTML width/height is being affected by $content_width. This should not happen. If a theme author wants it to not be wider than the theme width, then they wouldn't have set the width to be wider. Post thumbnails can be used outside of the content area.

Attachments (2)

12146.patch (655 bytes) - added by Viper007Bond 5 years ago.
12146.2.patch (1.8 KB) - added by Viper007Bond 5 years ago.
Use a bit of a hack to make the thumbnail fit in the meta box

Download all attachments as: .zip

Change History (7)

@Viper007Bond5 years ago

comment:1 @Viper007Bond5 years ago

A good example of this is the 2010 theme which uses a post's thumbnail as the header image in single post view.

comment:2 @Viper007Bond5 years ago

  • Keywords needs-testing added

Do only post thumbnails use $_wp_additional_image_sizes ?

comment:3 @automattor5 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [13103]) Do not limit thumbnails by the content_width. props Viper007Bond. fixes #12146

comment:4 @Viper007Bond5 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Unintended side-effect: post thumbnail preview on write screen is not downsized to fit. The meta box is was setting $content_width before to make it fit.

Rather than adding some other variable/global to replicate the old method, I think it'd just be easier to regex the HTML and modify the width/height.

@Viper007Bond5 years ago

Use a bit of a hack to make the thumbnail fit in the meta box

comment:5 @markjaquith5 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [13140]) Revert r13103 and merely restrict \$content_width obeying to is_admin(). fixes #12146

Note: See TracTickets for help on using tickets.