--- a/app/helpers/application_helper.rb 2013-12-15 11:45:55.960476540 +0000 +++ b/helpers/application_helper.rb 2013-12-15 12:49:41.032533340 +0000 @@ -573,6 +573,22 @@ m end end + text.gsub!(/!([^(!]+?)(\.bmp|gif|jpg|jpe|jpeg|png)\s?(?:\(((?:[^\(\)]|\([^\)]+\))+?)\))?\!/i) do |m| + filename= $1.downcase+$2 + alt = "alt=\"#{$3}\"" + # search for the picture in attachments + if found = Attachment.latest_attach(attachments, filename) + image_url = download_named_attachment_path(found, found.filename, :only_path => only_path) + desc = found.description.to_s.gsub('"', '') + if !desc.blank? + alt = " title=\"#{desc}\" alt=\"#{desc}\"" + end + "" + else + m + end + end + #One last effort to catch an attached image end end