Opened 10 years ago
Closed 10 years ago
#23945 closed defect (bug) (fixed)
get_the_post_format_image doesn't use specificed image size
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.6 | Priority: | normal |
Severity: | normal | Version: | 3.6 |
Component: | Post Formats | Keywords: | |
Focuses: | Cc: |
Description
Since setup_postdata() runs when the_post() is called and it sets $post->format_content using 'full' as the default image size there is no way to use get_the_post_format_image() or the_post_format_image() to specify a different size. get_the_post_format_image() returns $post->format_content if it's already set rather than retrieving the specified image size.
Attached patch removes the check for $post->format_content which allows the image size to be specified later.
Attachments (4)
Change History (16)
#4
@
10 years ago
23945.3.diff uses strpos()
instead of preg_match()
.
#5
follow-up:
↓ 6
@
10 years ago
@davidwilliamson Could you provide steps to repeat this? I'm able to get a custom post thumbnail size to work in Twenty Thirteen by using add_image_size( 'twentythirteen-image-post', 724, 1288 );
.
Related, though -- I'm running into a problem with WP.com and image sizes. We ignore "intermediate_image_sizes" since we use dynamic image sizing; which means the $sizes
loop in calculating which content to remove from content never runs.
I can open a new ticket for it since it's only semi-related to this one.
#6
in reply to:
↑ 5
@
10 years ago
Replying to lancewillett:
I can open a new ticket for it since it's only semi-related to this one.
See #24060
#7
follow-up:
↓ 8
@
10 years ago
@lancewillett: I just went in, updated trunk to r23974, switched themes to Twenty Thirteen, deleted all my content and re-uploaded the theme test data and regenerated thumbnails. I also created new image posts using the new workflow for 3.6 as well as ones like the test cases with significantly larger original images because the test images are smaller than the new size you are defining with add_image_size( 'twentythirteen-image-post', 724, 1288 );
. The problem is still there - although it isn't visible in Twenty Thirteen because of css rules unless you look at the page source. If you look at the source of the page and the image source is the full size version rather than the twentythirteen-image-post version and has the class attachment-full instead of the expected attachment-twentythirteen-image-post.
If you apply the patch attachment:23945.3.diff the class changes to attachment-twentythirteen-image-post and the image source is the corresponding resized version.
#8
in reply to:
↑ 7
;
follow-up:
↓ 9
@
10 years ago
Replying to davidwilliamson: Can you also please check if the patch in #24002 does the trick? Thanks!
attachment:23945.2.diff replaces the
if ( isset( $post->format_content ) )
with a check to see if the image already contained in$post->format_content
is the same size as what is being requested. I believe this more closely follows the original intent of the check for whether$post->format_content
is set rather than just deleting it all together.There may be a better way to check whether the image already contained in
$post->format_content
is the appropriate size but I'm not sure how. There also may very well be a better regex to use when checking, I am not very experienced with regular expressions.