zweitag / middleman-images

Resize and optimize images for Middleman
MIT License
17 stars 3 forks source link

Getting this extension to work #32

Closed dmerrick closed 5 years ago

dmerrick commented 6 years ago

Hey!

So last night I tried using this extension, but nothing happened every time I ran a build. I ended up digging into the code and realized that at the moment where the code is looking up the image in the sitemap...

app.sitemap.find_resource_by_path(absolute_image_path(url))

...was returning nil instead of the file resource it was supposed to. I changed find_resource_by_path() to find_resource_by_destination_path(), and now it works like a charm!

Not sure why it seems to be working for everyone else but not for me, but I figured I'd include my fix for anyone else who needs it.

Currently running Middleman 4.2.1

ChristianPeters commented 6 years ago

Hi Dana!

We are happy that the work we put into this extension might be useful for someone else. You're the first non-Zweitag user we know of – so it's possible "everyone else" is just us with one specific setting. :)

I'm sure @pmk1c will look into this once he's got the time to do it.

Thanks for letting us know about your issue!

pmk1c commented 6 years ago

Hi Dana,

sorry for the late response. I'm quite sure, we need to use find_resource_by_path here, since we want to get the resource by its path in the source files and not by the path, Middleman is building it to. Is it possible absolute_image_path isn't working for you? Do you have images_dir set in your config.rb?

FYI: We recently merged some bigger refactorings and performance improvements into master. You might find these changes helpful. We didn't release this Gem yet, since we still have to tackle some (performance) issues, that should be fixed before a proper release.