Hey all,
I’m looking for a way to embed an <img>
without having to specify its format extension. Has anyone written a helper for this?
I can accomplish it in Slim but it’s clunky and hard to reuse:
- data.people.each do |person|
- imagePath = "images/#{person.name.parameterize}"
- imageFormats = [".jpg", ".jpeg", ".png"]
- imageFound = false
- imageFormats.each do |imageFormat|
- image = "#{imagePath}#{imageFormat}"
- if sitemap.find_resource_by_path("#{image}")
img src="#{image}"
- imageFound = true
- break
- if imageFound == false
img src="/images/no-photo.jpg"
I’d rather write something like
= smart_image_tag '#{person.name.parameterize}'
Any help is appreciated!