Jekyll plugin that replaces pictures in Markdown documents by responsive images using jekyll-responsive-mage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Jekyll::Hooks.register :documents, :pre_render do |document, payload| | |
docExt = document.extname.tr('.', '') | |
# only process if we deal with a markdown file | |
if payload['site']['markdown_ext'].include? docExt | |
newContent = document.content.gsub(/!\[(.*)\]\((?:\/?([^\)\:\s]+))(?:\s"(.*)")?\)(?:{:([^}]+)})*/, '{% responsive_image path: \2 alt: "\1" title: "\3" %}') | |
document.content = newContent | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This Jekyll plugin replaces every Markdown pictures in Markdown documents by responsive images using jekyll-responsive-image's template.
For example:
will be replaced by