Make WordPress Core

Opened 15 years ago

Closed 15 years ago

#12146 closed defect (bug) (fixed)

Post thumbnails should not be affected by $content_width

Reported by: viper007bond's profile 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 15 years ago.
12146.2.patch (1.8 KB) - added by Viper007Bond 15 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)

@Viper007Bond
15 years ago

#1 @Viper007Bond
15 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.

#2 @Viper007Bond
15 years ago

  • Keywords needs-testing added

Do only post thumbnails use $_wp_additional_image_sizes ?

#3 @automattor
15 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

#4 @Viper007Bond
15 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.

@Viper007Bond
15 years ago

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

#5 @markjaquith
15 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.