2010-07-22 3 views

Répondre

2

Vous pouvez créer un nouveau filtre pour les images, et ajoutez le filtre dans un initialiseur, après avoir mis la gemme auto_html. Le filtre peut se présenter comme suit:

AutoHtml.add_filter(:sized_image).with(:width => INSERT_SOME_DEFAULT_HERE, :height => INSERT_SOME_DEFAULT_HERE) do |text, options| 

    text.gsub(/http:\/\/.+\.(jpg|jpeg|bmp|gif|png)(\?\S+)?/i) do |match| 
    width = options[:width] 
    height= options[:height] 
    %|<img src="#{match}" alt="" width="#{width}" height="#{height}" />| 
    end 
end 

Ceci est non testé, comme je l'ai pas encore accès au terminal, mais doit travailler ou obtenir au moins vous l'avez fait dans la bonne direction. Bonne chance!

+0

merci beaucoup ça fonctionne! – tabaluga