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:
parent
ff9c34bca9
commit
be2788b6ca
3 changed files with 20 additions and 6 deletions
|
@ -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"'
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
![Alt text](/images/blank.gif)
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue