Opened 3 years ago

Closed 3 years ago

#12146 closed defect (bug) (fixed)

Post thumbnails should not be affected by $content_width

Reported by: Viper007Bond Owned by:
Priority: normal Milestone: 3.0
Component: Post Thumbnails Version: 3.0
Severity: normal Keywords: has-patch needs-testing
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 3 years ago.
12146.2.patch (1.8 KB) - added by Viper007Bond 3 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)

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

  • Keywords needs-testing added

Do only post thumbnails use $_wp_additional_image_sizes ?

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

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

  • 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.

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

  • 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.