1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00

Fix automatic images with absolute (or images dir missing) paths in markdown. Fixes #1755

This commit is contained in:
Thomas Reynolds 2016-01-14 14:14:50 -08:00
parent ff9c34bca9
commit be2788b6ca
3 changed files with 20 additions and 6 deletions

View file

@ -2,15 +2,28 @@ Feature: Automatically detect and insert image dimensions into tags
In order to speed up development and appease YSlow
Scenario: Rendering an image with the feature disabled
Given "automatic_image_sizes" feature is "disabled"
Given a fixture app "automatic-image-size-app"
And a file named "config.rb" with:
"""
"""
And the Server is running at "automatic-image-size-app"
When I go to "/auto-image-sizes.html"
Then I should not see "width="
And I should not see "height="
When I go to "/markdown-sizes.html"
Then I should not see "width="
And I should not see "height="
Scenario: Rendering an image with the feature enabled
Given "automatic_image_sizes" feature is "enabled"
Given a fixture app "automatic-image-size-app"
And a file named "config.rb" with:
"""
activate :automatic_image_sizes
"""
And the Server is running at "automatic-image-size-app"
When I go to "/auto-image-sizes.html"
Then I should see "width="
And I should see "height="
Then I should see 'width="1"'
And I should see 'height="1"'
When I go to "/markdown-sizes.html"
Then I should see 'width="1"'
And I should see 'height="1"'

View file

@ -0,0 +1 @@
![Alt text](/images/blank.gif)

View file

@ -19,7 +19,7 @@ class Middleman::Extensions::AutomaticImageSizes < ::Middleman::Extension
real_path = path.dup
real_path = File.join(config[:images_dir], real_path) unless real_path.start_with?('/')
file = app.files.find(:source, real_path)
file = app.files.find(:source, real_path) || app.files.find(:source, real_path.gsub(/^\//, ''))
if file && file[:full_path].exist?
begin