Module: VenusMediaLibrary::ImagesHelper

Included in:
ImagesController, LegacyAssetsController, PickersController
Defined in:
app/helpers/venus_media_library/images_helper.rb

Overview

Shared image URL/payload logic. Included in the views (automatically) and in ImagesController so the HTML grid and the JSON response stay in sync.

Instance Method Summary collapse

Instance Method Details

#ml_blob_url(asset) ⇒ Object

Permanent URL to the original file. Active Storage route helpers live on the host app, so they are reached through the main_app proxy. With url_type = :proxy the URL streams through Rails (works for private buckets and external crawlers); the default :redirect 302s to the storage URL.



25
26
27
# File 'app/helpers/venus_media_library/images_helper.rb', line 25

def ml_blob_url(asset)
  venus_media_library.asset_path(asset)
end

#ml_image_payload(asset) ⇒ Object

A serializable description of a blob used by the JSON API and the tiles.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/helpers/venus_media_library/images_helper.rb', line 6

def ml_image_payload(asset)
  blob = asset.blob
  {
    id:           asset.id,
    signed_id:    blob.signed_id,
    filename:     blob.filename.to_s,
    content_type: blob.content_type,
    byte_size:    blob.byte_size,
    created_at:   blob.created_at,
    community_shared: asset.community_shared,
    url:          ml_blob_url(asset),
    thumb_url:    ml_thumb_url(asset)
  }
end

#ml_thumb_url(asset) ⇒ Object

Small variant used for the grid thumbnail. Falls back to the original URL when the blob can't be variated (e.g. SVG).



31
32
33
# File 'app/helpers/venus_media_library/images_helper.rb', line 31

def ml_thumb_url(asset)
  venus_media_library.thumbnail_asset_path(asset)
end