Skip to content

Instantly share code, notes, and snippets.

@jonknapp
jonknapp / image_path_tag.rb
Created September 19, 2014 18:38
Jekyll plugin to return <img> markup by only passing in the image filename and optional alt text. Image path is "/images/:year/:slug/:filename".
module Jekyll
class ImagePathTag < Liquid::Tag
@alt = nil
@url = nil
IMAGE_URL = /((https?:\/\/|\/)?(\S+))/i
IMAGE_URL_WITH_ALT = /((https?:\/\/|\/)?(\S+))(\s+)"(.*?)"/i
def initialize(tag_name, markup, tokens)
super