Make WordPress Core

Opened 14 years ago

Closed 6 years ago

#6430 closed enhancement (fixed)

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

Reported by: mlossos Owned by: wonderboymusic
Milestone: 4.4 Priority: normal
Severity: normal Version: 2.5
Component: XML-RPC Keywords: has-patch
Focuses: Cc:


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.)


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:


Using the default thumbnail settings of 150x150 and 300x300, these files will be created:

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 12 years ago.
Patch to add urls for resized images to the response
thumbnail.patch (1.3 KB) - added by jonquark 11 years ago.
Patch to return urls for smaller images for xmlrpc uploads
thumbnail_19Oct10.patch (1.7 KB) - added by jonquark 11 years ago.
v3 of the patch
thumbnail_27Oct10.patch (1.7 KB) - added by jonquark 11 years ago.
6430.diff (1.1 KB) - added by markoheijnen 9 years ago.

Download all attachments as: .zip

Change History (20)

#1 @josephscott
14 years ago

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

#2 @lloydbudd
14 years ago

  • Milestone changed from 2.5 to 2.6

#3 @redsweater
14 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.

#4 @Denis-de-Bernardy
12 years ago

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

12 years ago

Patch to add urls for resized images to the response

#5 @jonquark
12 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.

#6 @jonquark
12 years ago

I've created a (hopefully) temporary plugin to add this functionality:
until this item is closed.

11 years ago

Patch to return urls for smaller images for xmlrpc uploads

#7 @jonquark
11 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?

11 years ago

v3 of the patch

#8 @jonquark
11 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...

#9 @jonquark
11 years ago

v4 of the patch now added

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

#10 @josephscott
11 years ago

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

9 years ago

#11 @markoheijnen
9 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

#12 @markoheijnen
9 years ago

  • Keywords dev-feedback added

#13 @chriscct7
6 years ago

  • Keywords needs-refresh added; has-patch removed

#14 @wonderboymusic
6 years ago

  • Keywords has-patch added; dev-feedback needs-refresh removed
  • Milestone changed from Future Release to 4.4
  • Owner changed from jonquark to wonderboymusic
  • Status changed from accepted to assigned

#15 @wonderboymusic
6 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 34579:

XML-RPC: upgrade the resposnse ofwp_xmlrpc_server::mw_newMediaObject() based on work down in 3.4 so that it runs the struct through ->_prepare_media_item().

Props markoheijnen.
Fixes #6430.

Note: See TracTickets for help on using tickets.