Sha256: 867b3a56590e7e2f9273fd37eb1e7e92203488cbe0643e530d43004d0f427e7d

Contents?: true

Size: 879 Bytes

Versions: 2

Compression:

Stored size: 879 Bytes

Contents

# frozen_string_literal: true

module Spotlight
  # Handles requests to upload images for exhibit thumbnails
  class FeaturedImagesController < Spotlight::ApplicationController
    load_and_authorize_resource instance_name: :featured_image

    def create
      if @featured_image.save && @featured_image.file_present?
        render json: { tilesource: tilesource, id: @featured_image.id }
      else
        render json: { error: 'unable to create image' }, status: :bad_request
      end
    end

    private

    def tilesource
      Spotlight::Engine.config.iiif_url_helpers.info_url(
        @featured_image.id,
        host: request.host_with_port
      )
    end

    # The create action can be called from a number of different forms, so
    # we normalize all the parameters.
    def create_params
      params.require(:featured_image).permit(:image)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
blacklight-spotlight-2.11.0 app/controllers/spotlight/featured_images_controller.rb
blacklight-spotlight-2.10.0 app/controllers/spotlight/featured_images_controller.rb