WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 2 years ago

#11993 new enhancement

Add post thumbnail from url

Reported by: paradox460 Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 2.9.1
Component: Post Thumbnails Keywords: thumbnail post
Focuses: Cc:

Description

If you got add a post thumbnail in 2.9, and use the "From URL" option, there is no link to set the image specified as the thumbnail. You can only put it in the post.

Change History (8)

comment:1 scribu4 years ago

  • Milestone changed from Unassigned to 3.0
  • Summary changed from When adding a post thumbnail from url, there is no option for setting the thumbnail to Add post thumbnail from url
  • Type changed from defect (bug) to enhancement

comment:2 nacin4 years ago

This is because we don't sideload the photo from a url and actually add it to the media library -- I'm a big fan of media_sideload_image() but we only use it in Press This.

comment:3 follow-up: Paradox4604 years ago

One thing that would be actually quite useful is the ability to specify a url, then have a "download to server" option, like MediaWiki provides.

I believe they just use CURL.

comment:4 in reply to: ↑ 3 nacin4 years ago

Replying to Paradox460:

One thing that would be actually quite useful is the ability to specify a url, then have a "download to server" option, like MediaWiki provides.

I believe they just use CURL.

We have a download_url() function that uses WP's HTTP API, which is used to download core/theme/plugin packages and in media_sideload_image(). media_sideload_image() is the ability you're looking for, though it is used only in Press This.

comment:5 nacin4 years ago

  • Milestone changed from 3.0 to 3.1

comment:6 nacin3 years ago

  • Milestone changed from Awaiting Triage to Future Release

comment:7 lgedeon2 years ago

media_sideload_image() can be extended to either:

  1. optionally return the attachment id (instead of html) so we can set_post_thumbnail( $post, $id ) with the results
  2. or we could include set_post_thumbnail( $post, $id ) in the function and add a boolean that says to make it the featured image
  3. or we could extract getting the attachment id into another function and make this function only responsible for building the html. Then if all I need is the id, I can call the extracted function instead.

I would love to write this patch, but would like to get your thoughts on preferred approach.

comment:8 lgedeon2 years ago

  • Cc luke.gedeon@… added
Note: See TracTickets for help on using tickets.