WP::API::Media - An interface for WordPress media objects
use File::Slurp qw( read_file ); my $content = read_file('path/to/file.jpg'); my $media = $api->media()->create( name => 'foo.jpg', type => 'image/jpeg', bits => $content, overwrite => 1, ); print $media->date_created_gmt()->date(); my $other_media = $api->media()->new( attachment_id => 99 ); print $other_media->title();
This class provides methods for creating new media objects and fetching data about existing media objects.
See the WordPress API documentation at http://codex.wordpress.org/XML-RPC_WordPress_API for more details on what all of the fields mean.
This class provides the following methods:
This method constructs a new media object based on data from the WordPress server. The only accepted parameter is a
attachment_id, which is required.
This method creates a new media object on the WordPress server. It accepts a hash with the following keys as of WordPress 3.5:
The object's file name.
The object's MIME type.
The raw media object content.
A boolean indicating whether or not to overwrite an existing file with the same name.
Note that if future versions of WordPress accept more parameter, this API allows you to pass them. Any key/value pairs you pass will be sent to WordPress as-is.
Returns the media object's creation date and time as a DateTime object in the UTC time zone.
Returns the post_id of the media object's parent or 0 if it doesn't have one.
Returns the full URI of the media object as a URI object.
Returns the media object's title.
Returns the media object's caption if it has one,
Returns the media object's description if it has one,
Returns a rather complicated hash reference. See the WordPress API documentation for details.
Note that this might become a set of real objects in the future.
Returns the thumbnail URI of the media object as a URI object.
Dave Rolsky <firstname.lastname@example.org>
This software is Copyright (c) 2013 by Dave Rolsky.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)