Skip to content

Commit

Permalink
Fixes #1628 by updating Dragonfly API usage.
Browse files Browse the repository at this point in the history
  • Loading branch information
parndt committed May 12, 2012
1 parent 47cca18 commit 20c0169
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions core/app/helpers/refinery/image_helper.rb
Expand Up @@ -6,18 +6,16 @@ module ImageHelper
# replace all system images with a thumbnail version of them (handy for all images inside a page part)
# for example, <%= content_fu(@page.content_for(:body), '96x96#c') %> converts all /system/images to a 96x96 cropped thumbnail
def content_fu(content, thumbnail)
content.gsub(%r{<img.+?src=['"](/system/images/.+?)/.+?/>}) do |image_match|
begin
uid = Dragonfly::Job.from_path(
"#{image_match.match(%r{(/system/images/.+?)/})[1]}", Dragonfly[:refinery_images]
).uid
content.gsub(%r{<img.+?src=['"](/system/images/.+?)/.+?/>}) do |img|
begin
sha = img.match(%r{/system/images/(.+?)/})[1]
job = Dragonfly::Job.deserialize sha, Dragonfly[:refinery_images]

image_fu Image.where(:image_uid => uid).first, thumbnail
rescue
# FAIL, don't care why but return what we found initially.
image_match
end
end
image_fu Image.where(:image_uid => job.uid).first, thumbnail
rescue Dragonfly::Serializer::BadString
img
end
end
end

# image_fu is a helper for inserting an image that has been uploaded into a template.
Expand Down

0 comments on commit 20c0169

Please sign in to comment.