lib/isodoc/function/utils.rb in isodoc-0.10.1 vs lib/isodoc/function/utils.rb in isodoc-0.10.2

- old
+ new

@@ -141,7 +141,17 @@ gsub(/\s*\[MODIFICATION\]/, l10n(", #{@modified_lbl} &mdash; ")) template = liquid(docxml) template.render(meta.map { |k, v| [k.to_s, empty2nil(v)] }.to_h). gsub('&lt;', '&#x3c;').gsub('&gt;', '&#x3e;').gsub('&amp;', '&#x26;') end + + def save_dataimage(uri, relative_dir = true) + %r{^data:image/(?<imgtype>[^;]+);base64,(?<imgdata>.+)$} =~ uri + uuid = UUIDTools::UUID.random_create.to_s + fname = "#{uuid}.#{imgtype}" + new_file = File.join(tmpimagedir, fname) + @files_to_delete << new_file + File.open(new_file, "wb") { |f| f.write(Base64.strict_decode64(imgdata)) } + File.join(relative_dir ? rel_tmpimagedir : tmpimagedir, fname) + end end end