NAME
Mojolicious::Plugin::Cloudinary - Talk with cloudinary.com
DESCRIPTION
This register the methods from the Cloudinary module as helpers in your Mojolicious web application. See "HELPERS" for details.
SYNOPSIS
package MyWebApp;
use Mojo::Base 'Mojolicious';
sub startup {
my $self = shift;
$self->plugin('Mojolicious::Plugin::Cloudinary', {
cloud_name => $str,
api_key => $str,
api_secret => $str,
});
}
package MyWebApp::SomeController;
sub upload {
my $self = shift;
$self->render_later;
$self->cloudinary_upload({
file => $self->param('upload_param'),
on_success => sub {
my $res = shift;
$self->render_json($res);
},
on_error => sub {
my $res = shift || { error => 'Unknown' };
$self->render_json($res);
},
});
}
ATTRIBUTES
js_image
This string will be used as the image src for images constructed by "cloudinary_js_image". The default is "/image/blank.png".
HELPERS
cloudinary_upload
cloudinary_destroy
cloudinary_url_for
cloudinary_image
$str = $c->cloudinary_image($public_id, $url_for_args, $image_args);
This will use "image" in Mojolicious::Plugin::TagHelpers to create an image tag where "src" is set to a cloudinary image. $url_for_args
are passed on to "url_for" and $image_args
are passed on to "image" in Mojolicious::Plugin::TagHelpers.
cloudinary_js_image
$str = $c->cloudinary_js_image($public_id, $url_for_args);
About the same as "cloudinary_image", except it creates an image which can handled by the cloudinary jQuery plugin which you can read more about here: http://cloudinary.com/blog/cloudinary_s_jquery_library_for_embedding_and_transforming_images
Example usage:
$c->cloudinary_js_image(1234567890 => {
width => 115,
height => 115,
crop => 'thumb',
gravity => 'faces',
radius => '20',
});
...will produce:
<img src="/image/blank.png"
class="cloudinary-js-image"
alt="1234567890"
data-src="1234567890"
data-width="115"
data-height="135"
data-crop="thumb"
data-gravity="faces"
data-radius="20">
Note: The "class" and "alt" attributes are fixed for now.
METHODS
register
Will register the "HELPERS" in the Mojolicious application.
COPYRIGHT & LICENSE
See Cloudinary.
AUTHOR
Jan Henning Thorsen - jhthorsen@cpan.org