The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

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

  use Mojolicious::Lite;

  plugin cloudinary => {cloud_name => $str, api_key => $str, api_secret => $str};

  post "/upload" => sub {
    my $c = shift;

    $c->delay(
      sub {
        my ($delay) = @_;
        $c->cloudinary_upload({file => $c->param("upload_param")}, $delay->begin);
      },
      sub {
        my ($delay, $res, $tx) = @_;
        return $c->render(json => $res) if $res;
        return $c->render_exception;
      },
    );
  }

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

See "upload" in Cloudinary.

cloudinary_destroy

See "destroy" in Cloudinary.

cloudinary_url_for

See "url_for" in Cloudinary.

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.

SEE ALSO

Cloudinary.