Sha256: 75036008c4427cb217e0a78ba6277d519874d64248c0f2a0fb4ed71af304d0be
Contents?: true
Size: 1018 Bytes
Versions: 4
Compression:
Stored size: 1018 Bytes
Contents
require 'liquid' module Redmineup module Liquid module Filters module Additional def parse_inline_attachments(text, obj) attachments = obj.attachments if obj.respond_to?(:attachments) if attachments.present? text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png))"(\s+alt="([^"]*)")?/i) do |m| filename, ext, alt, alttext = $1, $2, $3, $4 # search for the picture in attachments if found = Attachment.latest_attach(attachments, CGI.unescape(filename)) desc = found.description.to_s.delete('"') alt = " title=\"#{desc}\" alt=\"#{desc}\"" if !desc.blank? && alttext.blank? "src='data:image/#{found.content_type};base64,#{found.to_base64_string}' #{alt}" else m end end end text end end ::Liquid::Template.register_filter(Redmineup::Liquid::Filters::Additional) end end end
Version data entries
4 entries across 4 versions & 1 rubygems