Class: JekyllImgFlow::Providers::Weserv

Inherits:
HttpBase show all
Defined in:
lib/jekyll-imgflow/providers/weserv.rb

Overview

Weserv provider implementation using the standardized tag interface

Constant Summary collapse

TIMEOUT =
30
SVG_DEFAULT_MAX_SIZE =

SVGs without explicit pixel dimensions (e.g. width="100%") are valid but cause librsvg to rasterize at the viewBox size, which can be huge. When no resize operation is present, cap the rasterization at 2000px on the longest edge so weserv processes the SVG at a reasonable size.

2000

Constants inherited from BaseProvider

BaseProvider::COMPASS_TO_SHORT, BaseProvider::KNOWN_OPERATIONS, BaseProvider::SMARTCROP_POSITIONS

Instance Attribute Summary

Attributes inherited from BaseProvider

#config

Instance Method Summary collapse

Methods inherited from HttpBase

#available?, #execute

Methods inherited from BaseProvider

#add_watermark, #alpha_byte_value, #alpha_opacity=, #available?, #check_http_service, #cli_available?, #compass_to_short, #convert_format, #crop, #crop_coords, #crop_geometry, #encode_file_url, #execute, #find_op, #format, #initialize, #input_format_ext, #op?, #opacity, #operations, #optimize, provider_name, #quality, #quality=, #relative_file_path, #reset_operations, #resize, #smartcrop_interestingness, supports_operation?, #supports_operation?, #temp_path, unsupported_operations, #watermark, #watermark_parts

Constructor Details

This class inherits a constructor from JekyllImgFlow::Providers::BaseProvider

Instance Method Details

#build_combined_url(input_path) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/jekyll-imgflow/providers/weserv.rb', line 26

def build_combined_url(input_path)
  raise "weserv_url not set" unless service_url

  encoded_url = encode_file_url(input_path)
  params = ["url=#{URI.encode_www_form_component(encoded_url)}"]

  @operations.each { |operation| append_weserv_operation(operation, params) }

  ensure_svg_size_limit(input_path, params)

  "#{service_url}/?#{params.join('&')}"
end

#build_combined_weserv_url(input_path) ⇒ Object



22
23
24
# File 'lib/jekyll-imgflow/providers/weserv.rb', line 22

def build_combined_weserv_url(input_path)
  build_combined_url(input_path)
end

#service_url ⇒ Object



18
19
20
# File 'lib/jekyll-imgflow/providers/weserv.rb', line 18

def service_url
  @config.respond_to?(:weserv_url) ? @config.weserv_url : nil
end