WordPress.org

Make WordPress Core

Opened 7 years ago

Last modified 3 years ago

#6430 accepted enhancement

WordPress 2.5 xmlrpc should return image thumbnail URLs in wp.uploadFile

Reported by: mlossos Owned by: jonquark
Milestone: Future Release Priority: normal
Severity: normal Version: 2.5
Component: XML-RPC Keywords: has-patch dev-feedback
Focuses: Cc:

Description

The xmlrpc call for wp.uploadFile (aliased to mw_newMediaObject) currently returns the URL of the uploaded file only. In WordPress 2.5, thumbnail files are automatically created. The xmlrpc API should provide a way to get the URLs of the thumbnail files, preferably in the returned hash from the wp.uploadFile call.

That is, wp.uploadFile currently returns url = "http://myhost/wp/wp-content/uploads/2008/03/myImage.jpg". In addition, it should return "thumbnailSmallUrl = ..." and "thumbnailMediumUrl = ...". (I'm not sure if this would break MetaWeblog compatibility.)

Background:

WordPress 2.5 now automatically creates thumbnail images for uploaded image files according to the (maximum) sizes specified in the Miscellaneous settings page. When resizing, the aspect ratio is maintained, and the filenames are named for the exact size of the image. For example, if I upload:

dsc-0151.jpg

Using the default thumbnail settings of 150x150 and 300x300, these files will be created:
dsc-0151-300x199.jpg
dsc-0151-150x150.jpg

Note that the first filename for the medium thumbnail is called "300x199" not "300x300". It's thus difficult to guess the new thumbnail filename for the default settings.

Since these settings are user configurable, it's currently impossible for an xmlrpc client to guess the URLs of the thumbnails.

Attachments (5)

thumbnailurl.patch (1.3 KB) - added by jonquark 5 years ago.
Patch to add urls for resized images to the response
thumbnail.patch (1.3 KB) - added by jonquark 5 years ago.
Patch to return urls for smaller images for xmlrpc uploads
thumbnail_19Oct10.patch (1.7 KB) - added by jonquark 5 years ago.
v3 of the patch
thumbnail_27Oct10.patch (1.7 KB) - added by jonquark 5 years ago.
6430.diff (1.1 KB) - added by markoheijnen 3 years ago.

Download all attachments as: .zip

Change History (17)

comment:1 @josephscott7 years ago

  • Cc josephscott added
  • Component changed from General to XML-RPC
  • Type changed from defect to enhancement

comment:2 @lloydbudd7 years ago

  • Milestone changed from 2.5 to 2.6

comment:3 @redsweater7 years ago

  • Cc redsweater added

This is a great suggestion. I would also like to be able to offer WordPress-generated thumbnails to my users.

comment:4 @Denis-de-Bernardy6 years ago

  • Keywords needs-patch added
  • Milestone changed from 2.9 to Future Release

@jonquark5 years ago

Patch to add urls for resized images to the response

comment:5 @jonquark5 years ago

  • Cc jonquark added
  • Keywords has-patch added; needs-patch removed
  • Owner changed from anonymous to jonquark
  • Status changed from new to accepted

It's my first Wordpress patch, please review it harshly.

comment:6 @jonquark5 years ago

I've created a (hopefully) temporary plugin to add this functionality:
http://wordpress.org/extend/plugins/imageurlreturner/
until this item is closed.

@jonquark5 years ago

Patch to return urls for smaller images for xmlrpc uploads

comment:7 @jonquark5 years ago

I've just updated the patch so it now applies to trunk revision 15490 (checked out this evening).

Now 3.0 is out and stable, is now a good time to ask for this patch to be applied?

@jonquark5 years ago

v3 of the patch

comment:8 @jonquark5 years ago

I've added another version of the patch (against rev. 15853).

In addition to keeping up with trunk changes, I've fixed a problem where the urls weren't returned correctly when two files of the same name were uploaded to the server.

(Thanks to multiple people for pointing out the problem which they encountered using the plugin equivalent to this patch).

I'd be really grateful if the patch could be applied...

comment:9 @jonquark5 years ago

v4 of the patch now added

(v3 of the patch had inadvertent changes due to mistaken forward porting from the original patch)

comment:10 @josephscott4 years ago

Perhaps we should look at returning the same set of data provided by the new wp.getMediaItem method - #15151

@markoheijnen3 years ago

comment:11 @markoheijnen3 years ago

I've added a new patch to benefit from the work that has been done in 3.4.
The deprecated values its a little bit ugly but I guess this is the only way to make things the same trough all wp methods

comment:12 @markoheijnen3 years ago

  • Keywords dev-feedback added
Note: See TracTickets for help on using tickets.