Opened 7 years ago
Closed 7 years ago
#39759 closed enhancement (fixed)
Make $thumbnail_id filterable in embed-content.php
Reported by: | Ov3rfly | Owned by: | ketuchetan |
---|---|---|---|
Milestone: | 4.9 | Priority: | normal |
Severity: | normal | Version: | 4.4 |
Component: | Embeds | Keywords: | has-patch good-first-bug needs-testing |
Focuses: | Cc: |
Description
Some images from photo agencies have special terms where/how to publish them. Use outside of the website might be prohibited.
To be able to filter/replace these images (by looking at their title, description, excerpt or similar) a filter in embed-content.php would be helpful.
Currently a theme needs to provide a modified copy of embed-content.php to catch these cases. Other details (size, shape) can be filtered already, but not the image itself.
Suggested endhancement:
if ( 'attachment' === get_post_type() && wp_attachment_is_image() ) { $thumbnail_id = get_the_ID(); } // add this: $thumbnail_id = apply_filters( 'embed_thumbnail_id', $thumbnail_id ); if ( $thumbnail_id ) {
Thanks for considering.
Attachments (6)
Change History (22)
#1
@
7 years ago
- Keywords needs-patch good-first-bug added
- Milestone changed from Awaiting Review to Future Release
#2
@
7 years ago
- Keywords has-patch added; needs-patch good-first-bug removed
Hi @swissspidy,
I have added the filter for the $thumbnail_id
Thanks,
#3
@
7 years ago
- Keywords good-first-bug added
- Version changed from 4.7.2 to 4.4
@jontyravi @Dency The filter needs to be documented according to our PHP Documentation Standards. Note to use tabs for indentation, not spaces.
#4
@
7 years ago
- Keywords good-first-bug removed
Hi @swissspidy
I have updated the patch with the proper documentation.
Thanks,
#5
@
7 years ago
- Keywords good-first-bug added
- Owner set to ketuchetan
- Status changed from new to assigned
Please note that the good-first-bug keyword is usually not removed. Instead we assign tickets to an individual contributor working on a solution to mark this good-first-bug as claimed.
#6
@
7 years ago
- Milestone changed from Future Release to 4.8
Moving to the milestone for consideration.
Patch needs a few corrections:
@since
should be 4.8.0, not 4.4. We can't time travel :)- filter description needs a trailing dot
This ticket was mentioned in Slack in #core by jeffpaul. View the logs.
7 years ago
This ticket was mentioned in Slack in #core by jeffpaul. View the logs.
7 years ago
#12
@
7 years ago
I applied the patch to the latest WordPress build, but the "embed-content.php" file doesn't get called if I embed a post in an iframe. So I'm not able to test how this works.
Repro:
- in the root of the WordPress, create a simple HTML file with an IFRAME which includes an existing post. Let's say test.html
- load http://src.wordpress-develop.dev/test.html -> it displays ok in browser, but the embed-content.php file doesn't get called.
Expected behavior: embed-content.php should get called when the IFRAME is loaded in a browser.
#13
@
7 years ago
@mariusvetrici That's not exactly how it works. embed-content.php
is used for oEmbed, i.e. when you paste the URL to a post on a single line, or when you manually include the embed code for a post. (check the REST API or get_post_embed_html()
). The embed code is an iframe, but the URL for a post looks like example.com/my-post/embed/ instead of example.com/my-post/.
Added filter for the thumbnail_id