fix auto image sizes
This commit is contained in:
parent
0f9d5c7ec5
commit
de6a4679a6
|
@ -6,10 +6,10 @@ class Middleman::Base
|
||||||
def image_tag(path, params={})
|
def image_tag(path, params={})
|
||||||
if (!params[:width] || !params[:height]) && !path.include?("://")
|
if (!params[:width] || !params[:height]) && !path.include?("://")
|
||||||
params[:alt] ||= ""
|
params[:alt] ||= ""
|
||||||
prefix = options.http_images_path rescue options.images_dir
|
http_prefix = options.http_images_path rescue options.images_dir
|
||||||
|
|
||||||
begin
|
begin
|
||||||
real_path = File.join(options.public, asset_url(path, prefix))
|
real_path = File.join(options.public, options.images_dir, path)
|
||||||
if File.exists? real_path
|
if File.exists? real_path
|
||||||
dimensions = Middleman::FastImage.size(real_path, :raise_on_failure => true)
|
dimensions = Middleman::FastImage.size(real_path, :raise_on_failure => true)
|
||||||
params[:width] ||= dimensions[0]
|
params[:width] ||= dimensions[0]
|
||||||
|
@ -18,7 +18,7 @@ class Middleman::Base
|
||||||
rescue
|
rescue
|
||||||
end
|
end
|
||||||
|
|
||||||
params = params.merge(:src => asset_url(path, prefix))
|
params = params.merge(:src => asset_url(path, http_prefix))
|
||||||
params = params.map { |k,v| %Q{#{k}="#{v}"}}.join(' ')
|
params = params.map { |k,v| %Q{#{k}="#{v}"}}.join(' ')
|
||||||
"<img #{params} />"
|
"<img #{params} />"
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue