lib/bridgetown-cloudinary/builder.rb in bridgetown-cloudinary-1.0.2 vs lib/bridgetown-cloudinary/builder.rb in bridgetown-cloudinary-1.1.0

- old
+ new

@@ -30,10 +30,14 @@ }) generator :add_image_urls_to_documents liquid_tag "cloudinary_img", :img_tag liquid_filter "cloudinary_url", :url_filter + if respond_to? :helper + helper "cloudinary_img", :img_helper + helper "cloudinary_url", :url_filter + end end # Populate front matter def add_image_urls_to_documents Bridgetown::Cloudinary::Utils.add_image_urls_to_documents( @@ -49,10 +53,15 @@ transformation&.delete! '"' "<img alt=\"#{alt}\" src=\"#{url_filter(id, transformation)}\" />" end - # Define the "cloudinary_url" Liquid filter + # Define the "cloudinary_img" Ruby helper + def img_helper(alt, id, transformation = nil) + "<img alt=\"#{alt}\" src=\"#{url_filter(id, transformation)}\" />" + end + + # Define the "cloudinary_url" Liquid filter / Ruby helper def url_filter(id, transformation = nil) Bridgetown::Cloudinary::Utils.url( config: config[:cloudinary], id: id, transformation: transformation ) end