Class: Oembed::ImageProvider
- Inherits:
-
Object
- Object
- Oembed::ImageProvider
- Defined in:
- app/services/oembed/image_provider.rb
Defined Under Namespace
Classes: ImageNotFoundError
Constant Summary collapse
- VALID_IMAGE_OPTIONS =
All valid options that can be passed to image_url
See Models::Imageable::VALID_IMAGE_URL_OPTIONS %i[ encode_format size borderx bordery size_modifier percentage width height crop_x crop_y crop_w crop_h crop_mode crop_last rotate relative hostname cache webp download optimize thumbnail background progressive_jpeg blur quality focus zoom radius border border_color ].freeze
- VALID_DISPLAY_OPTIONS =
Display options for the rendered tag
%i[ caption lazyload include_srcset sizes class alt link link_target wrapper_tag ].freeze
- DEFAULT_MAX_WIDTH =
Default max width to prevent enormous images from being inserted
The srcset will still provide smaller sizes for appropriate viewports 2000
Instance Method Summary collapse
-
#get(options = {}) ⇒ Hash
Get rendered image HTML.
Instance Method Details
#get(options = {}) ⇒ Hash
Get rendered image HTML
59 60 61 62 63 64 65 66 67 |
# File 'app/services/oembed/image_provider.rb', line 59 def get( = {}) image_id = [:image_id] raise ImageNotFoundError, 'No image ID provided' if image_id.blank? image = Image.find_by(id: image_id) raise ImageNotFoundError, "Image not found: #{image_id}" unless image build_response(image, ) end |