diff --git a/lib/jekyll-spaceship/cores/processor.rb b/lib/jekyll-spaceship/cores/processor.rb index 6479564..32946ee 100644 --- a/lib/jekyll-spaceship/cores/processor.rb +++ b/lib/jekyll-spaceship/cores/processor.rb @@ -192,5 +192,38 @@ module Jekyll::Spaceship end content end + + def self.fetch_img_data(url) + begin + res = Net::HTTP.get_response URI(url) + raise res.body unless res.is_a?(Net::HTTPSuccess) + content_type = res.header['Content-Type'] + raise 'Unknown content type!' if content_type.nil? + content_body = res.body.force_encoding('UTF-8') + return { + 'type' => content_type, + 'body' => content_body + } + rescue StandardError => msg + logger.log msg + end + end + + def self.make_img_tag(data) + css_class = data['class'] + type = data['type'] + body = data['body'] + if type == 'url' + "" + elsif type.include?('svg') + body.gsub(/\<\?xml.*?\?>/, '') + .gsub(//, '') + .sub(/" + end + end end end