diff --git a/README.md b/README.md index 6af69759..7c75a579 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,12 @@ Search will now automatically search DMSF content when a Redmine search is perfo ####An inline picture with custom size `{{dmsf_image(8, size=50%)}}` +####An inline picture with custom height +`{{dmsf_image(8, height=300)}}` + +####An inline picture with custom width +`{{dmsf_image(8, width=300)}}` + ####An inline picture with custom size `{{dmsf_image(8, size=640x480)}}` diff --git a/init.rb b/init.rb index 29b434c5..97eb72cd 100644 --- a/init.rb +++ b/init.rb @@ -171,29 +171,26 @@ Redmine::Plugin.register :redmine_dmsf do "{{dmsf_image(file_id, size=300)}} -- with custom title and size\n" + "{{dmsf_image(file_id, size=640x480)}}" macro :dmsf_image do |obj, args| - args, options = extract_macro_options(args, :size, :width, :title) + args, options = extract_macro_options(args, :size, :width, :height, :title) file_id = args.first raise 'DMSF document ID required' unless file_id.present? size = options[:size] width = options[:width] + height = options[:height] if file = DmsfFile.find_by_id(file_id) unless User.current && User.current.allowed_to?(:view_dmsf_files, file.project) raise l(:notice_not_authorized) end raise 'Not supported image format' unless file.image? url = url_for(:controller => :dmsf_files, :action => 'view', :id => file) - if size - if size.include? "%" - image_tag(url, :alt => file.title, :width => size, :height => size) - elsif size.include? "x" - image_tag(url, :alt => file.title, :size => size) - else - image_tag(url, :alt => file.title, :width => 'auto', :height => size) - end + if size and size.include? "%" + image_tag(url, :alt => file.title, :width => size, :height => size) + elsif height + image_tag(url, :alt => file.title, :width => 'auto', :height => height) elsif width image_tag(url, :alt => file.title, :width => width, :height => 'auto') else - image_tag(url, :alt => file.title, :width => 'auto', :height => size) + image_tag(url, :alt => file.title, :size => size) end else raise "Document ID #{file_id} not found"