Opened 9 years ago
Closed 9 years ago
#34807 closed defect (bug) (fixed)
Image tags without ending slash are never made responsive.
Reported by: | programmin | Owned by: | wonderboymusic |
---|---|---|---|
Milestone: | 4.4 | Priority: | normal |
Severity: | normal | Version: | 4.4 |
Component: | Media | Keywords: | has-patch commit |
Focuses: | performance | Cc: |
Description
If a page has this content:
<div>some content</div> <div style="text-align: right;">more content</div> <div style="text-align: center;"> <img class="alignnone size-full wp-image-2457" src="http://localhost/wordpress/wp-content/uploads/2015/11/IMG1275.jpg" alt="IMG1275" width="1536" height="2048"> </div>
the srcset is never added to the image - maybe a bug in wp_make_content_images_responsive() or get_media_embedded_in_content() as it returns empty array.
However, when I add an ending /> or </img> to the img tag it fixes it and I see srcset and responsive images.
Attachments (3)
Change History (13)
#1
@
9 years ago
- Component changed from General to Media
- Milestone changed from Awaiting Review to 4.4
#2
@
9 years ago
- Keywords has-patch added
In 34807.patch: use specific (shorter and faster) regex to match all images in post_content. Fixes the above bug and returns early when no images.
This ticket was mentioned in Slack in #feature-respimg by azaozz. View the logs.
9 years ago
#5
@
9 years ago
Yes, those functions should have been flushed down the toilet with most of the PF code from 3.6. They only existed to DRY when the internals would have otherwise been used 8-10 times. RIP
#6
@
9 years ago
Works for me. Using get_media_embedded_in_content()
was an idea introduced in #33641, which I wasn't super confident in at the time.
Confirmed. The bug is in get_media_embedded_in_content(). Why do we use that (buggy) function with longer regex for images anyway? If I remember right we had better and twice as fast regex specifically for images.
Using get_media_embedded_in_content() also has an unexpected/unintended side effect:
img
can be removed from the whitelist by using themedia_embedded_in_content_allowed_types
filter. That will of course prevent matching of any images.