Class: VenusMediaLibrary::PickersController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- VenusMediaLibrary::PickersController
- Includes:
- ImagesHelper
- Defined in:
- app/controllers/venus_media_library/pickers_controller.rb
Overview
Renders the picker modal body as a Turbo Frame. target is the DOM id of the
host input that a chosen image URL / signed_id should be written into.
Instance Method Summary collapse
Methods included from ImagesHelper
#ml_blob_url, #ml_image_payload, #ml_thumb_url
Instance Method Details
#show ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/venus_media_library/pickers_controller.rb', line 7 def show @target = params[:target].to_s @page = [ params.fetch(:page, 1).to_i, 1 ].max per = [ VenusMediaLibrary.configuration.per_page.to_i, 1 ].max.clamp(1, ImagesController::MAX_PER_PAGE) offset = (@page - 1) * per scope = visible_media_assets @has_more = offset + per < scope.count @images = scope.order(created_at: :desc).offset(offset).limit(per).map { |asset| ml_image_payload(asset) } render partial: "venus_media_library/pickers/picker", locals: { target: @target, images: @images, page: @page, has_more: @has_more }, layout: false end |