module Asciidoctor::Image

Constants

DataUriRx
FormatAliases

Public Class Methods

format(image_path, attributes = nil) click to toggle source
# File lib/asciidoctor/pdf/ext/asciidoctor/image.rb, line 9
def format image_path, attributes = nil
  (attributes && attributes['format']) || ((ext = ::File.extname image_path).downcase.slice 1, ext.length)
end
target_and_format(image_path, attributes = nil) click to toggle source
# File lib/asciidoctor/pdf/ext/asciidoctor/image.rb, line 13
def target_and_format image_path, attributes = nil
  if (image_path.start_with? 'data:') && (m = DataUriRx.match image_path)
    [(m[:data].extend ::Base64), (FormatAliases.fetch m[:fmt], m[:fmt])]
  else
    [image_path, (attributes && attributes['format']) || ((ext = ::File.extname image_path).downcase.slice 1, ext.length)]
  end
end

Public Instance Methods

format() click to toggle source
# File lib/asciidoctor/pdf/ext/asciidoctor/image.rb, line 22
def format
  (attr 'format', nil, false) || ((ext = ::File.extname(inline? ? target : (attr 'target'))).downcase.slice 1, ext.length)
end
target_and_format() click to toggle source
# File lib/asciidoctor/pdf/ext/asciidoctor/image.rb, line 26
def target_and_format
  image_path = inline? ? target : (attr 'target')
  if (image_path.start_with? 'data:') && (m = DataUriRx.match image_path)
    [(m[:data].extend ::Base64), (FormatAliases.fetch m[:fmt], m[:fmt])]
  else
    [image_path, (attr 'format', nil, false) || ((ext = ::File.extname image_path).downcase.slice 1, ext.length)]
  end
end