#23593 closed enhancement (duplicate)
Add functions to extract the first image from content, [gallery] a post, or an arbitrary string
Reported by: | wonderboymusic | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Post Formats | Keywords: | has-patch |
Focuses: | Cc: |
Description
Scenarios
A post has a post format of Image, but the current theme does not support the Image post format but:
- There's a gallery shortcode in the content and you want the first image
- There are images attached to the post and you want the first one
- There is an image tag as the content or in the content and you want the src
- The content is a URL representing an image
- The content is a URL representing an image, followed by new line(s), followed by commentary
Introduce the_image()
, get_the_image( $post_id = 0 )
, get_content_image( &$content, $remove = false )
, get_post_images( $post_id = 0 )
Attachments (1)
Change History (11)
#2
@
12 years ago
Justin Tadlock has a plugin with 250,000+ downloads called Get The Image, and its main function is called get_the_image()
. We should avoid introducing a function of the same name into core. Maybe get_post_image()
(and the corresponding post_image()
) instead?
#3
@
12 years ago
We should avoid introducing a function of the same name into core.
I disagree. Justin should prefix all the things in his plugins.
#4
@
12 years ago
We should avoid introducing a function of the same name into core.
I disagree. Justin should prefix all the things in his plugins.
I agree that developers should prefix, however, putting the users ahead of ourselves, we should avoid the conflict by not using the same function name as a popular plugin, or by taking over the function from the plugin by deactivating the plugin (as long as our version is compatible).
When core added the Sidebars, there was an existing plugin which didn't prefix, there's some code that we added to disable the plugin when the upgraded version of WordPress was installed, seamless transition from plugin to core feature. Just saying, there's precedent there if we take that route, but would probably require our function becoming pluggable.
#5
@
12 years ago
Many themes dependent on Justin's plugin use get_the_image()
in their template files. Asking everyone to change is a non-starter.
Might I suggest wp_get_the_image()
?
#9
@
12 years ago
- Milestone 3.6 deleted
- Resolution set to duplicate
- Status changed from new to closed
Duplicate of #22960.
Related: #22960