Skip to content

Instantly share code, notes, and snippets.

@ghiden
Created August 10, 2010 02:39
Show Gist options
  • Save ghiden/516567 to your computer and use it in GitHub Desktop.
Save ghiden/516567 to your computer and use it in GitHub Desktop.
$ git diff
diff --git a/init.rb b/init.rb
index f0a5316..29f7a2d 100644
--- a/init.rb
+++ b/init.rb
@@ -73,6 +73,14 @@ Redmine::WikiFormatting::Macros.register do
:id => attach.id,
:filename => attach.filename
+ thumb_filename = "#{tw}_#{th}_#{attach.disk_filename}"
+ unless File.exists? "public/thumbs/#{thumb_filename}"
+ image.resize "#{tw}x#{th}"
+ FileUtils.mkdir("public/thumbs") unless File.exists? "public/thumbs"
+ image.write("public/thumbs/#{thumb_filename}")
+ end
+ thumb_link = "/thumbs/#{thumb_filename}"
+
if ((tw == 0 || image[:width] < tw) && (th == 0 || image[:height] < th))
html = <<-eos
<img src="#{attach_link}" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment