Class: VenusMediaLibrary::LegacyAssetsController

Inherits:
ApplicationController show all
Includes:
ImagesHelper
Defined in:
app/controllers/venus_media_library/legacy_assets_controller.rb

Instance Method Summary collapse

Methods included from ImagesHelper

#ml_blob_url, #ml_image_payload, #ml_thumb_url

Instance Method Details

#importObject



30
31
32
33
34
35
36
37
38
# File 'app/controllers/venus_media_library/legacy_assets_controller.rb', line 30

def import
  blob = unowned_legacy_image_blobs.find(params[:id])
  asset = VenusMediaLibrary::Asset.create!(blob: blob, owner: venus_media_library_user)

  respond_to do |format|
    format.html { redirect_to images_path, notice: "Legacy upload imported into your private library." }
    format.json { render json: ml_image_payload(asset), status: :created }
  end
end

#indexObject



6
7
8
9
10
11
12
13
# File 'app/controllers/venus_media_library/legacy_assets_controller.rb', line 6

def index
  @legacy_blobs = unowned_legacy_image_blobs.order(created_at: :desc)

  respond_to do |format|
    format.html
    format.json { render json: { images: @legacy_blobs.map { |blob| legacy_image_payload(blob) } } }
  end
end

#showObject



15
16
17
18
# File 'app/controllers/venus_media_library/legacy_assets_controller.rb', line 15

def show
  blob = unowned_legacy_image_blobs.find(params[:id])
  send_data blob.download, filename: blob.filename.to_s, type: blob.content_type, disposition: "inline"
end

#thumbnailObject



20
21
22
23
24
25
26
27
28
# File 'app/controllers/venus_media_library/legacy_assets_controller.rb', line 20

def thumbnail
  blob = unowned_legacy_image_blobs.find(params[:id])
  return redirect_to legacy_asset_path(blob) unless blob.variable?

  width, height = VenusMediaLibrary.configuration.thumbnail_size
  representation = blob.variant(resize_to_limit: [ width, height ]).processed
  send_data representation.download, filename: blob.filename.to_s,
    type: representation.image.content_type, disposition: "inline"
end