Methods

Files

Class Index [+]

Quicksearch

UbiquoMedia

Media

Ubiquo template provides a simple media management for your application.

By default, the most common asset types are already created (video, flash, document, audio, image, other). Edit the fixtures file db/dev_bootstrap/asset_types.yml to add more.

Asset files will be store at public/media/assets/id.

Add media to your models

The media library allows to insert a media field into a model. On this example we include a media_attachment attribute called images, with a maximum of 2 elements and accepting only images.

  class ExampleModel
         media_attachment :images, :size => 2, :types => ["image"]
    ...
  end

Note: For convention, the attribute name should be always plural no matter if it contains a single element (size option is 1). The media_attachment accessor always returns an array.

media_attachment creates some methods on the object which can be useful on validations:

  validates_length_of :images_ids, :minumum => 1, :message => t('should contain at least one image')

Add media selectors to your views

In your views you only need to use the media_selector helper:

  <% form_for ... do |form| %>
         ....
         <%= media_selector form, :images %>
         ....
  <% end %>

Add media to your views

Get an url to your media with url_for_media_attachment:

  <%= link_to("a link to first image image", url_for_media_attachment(object.images.first)) %>

Using thumbnails

Generate url for your media columns with url_for_media_attachment and the magick version parameter:

  <%= link_to("a link to first thumbnail image", url_for_media_attachment(object.thumbnail.first, :thumb)) %>

 You can also specify paperclip styles to store different versions of the asset

Public Class Methods

version() click to toggle source

(Not documented)

   # File vendor/plugins/ubiquo_media/lib/ubiquo_media/version.rb, line 2
2:   def self.version
3:     VERSION::STRING
4:   end

Disabled; run with $DEBUG to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.