Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Feature request: filename in URL #22

Closed
parndt opened this Issue · 7 comments

4 participants

@parndt

By default dragonfly urls don't end with an extension for the file they are representing e.g.:
/assets/BAhbB1sHOgZmIiMyMDEwLzA5LzAxL1NTQ19DbGllbnRfQ29uZi5qcGdbCDoGcDoKdGh1bWIiDjk0MngzNjAjYw

This causes things like lightbox scripts to fail because they are looking for extensions.

A better URL is something like this:

/system/images/BAhbB1sHOgZmIiMyMDEwLzA5LzAxL1NTQ19DbGllbnRfQ29uZi5qcGdbCDoGcDoKdGh1bWIiDjk0MngzNjAjYw/image_name.jpg

We have managed to achieve this in Refinery CMS using this wee instance_eval:
http://github.com/resolve/refinerycms/blob/master/vendor/refinerycms/images/lib/images.rb#L48-L62

It'd be nice to have core support for this, maybe as an option passed to the dragonfly configuration that puts the filename at the end by default. As it is, we have to get it using the job.steps where we look for one with step_name :fetch.

@markevans
Owner

Hi - there is core support for this! :)
see 'suffix' bit of http://markevans.github.com/dragonfly/file.URLs.html

@parndt

Ah excellent! Thanks Mark ;)

@oliverbarnes

Hey Mark, I'm trying to get the original filename on the url too, to detect it in tests... But haven't managed to use the suffix proc example on the docs. What's the proper Rails 3 route that would go with that config?

@markevans
Owner

hi - I'm currently working on making this easier as at the moment it's a bit tricky having the original filename available at the time that you generate the url.

In the meantime, the best way is probably to pass the name in each time as a suffix
image.url(:suffix => name)
where name has been saved on your model (you can just add the attachment_name column and it should just work) and then wrap this in a helper.

if you use Rails 3 routes you'd need to have all the necessary information in the url - what kind of thing are you using it for? is it standard image thumbnails for a model attachment?

@oliverbarnes

yes, image thumbs for a model attachment, only accessed from an iphone app

adding attachment_name works well :) thanks

https://gist.github.com/880522 (tried embedding but it didn't render ?)

@markevans
Owner

cool - hopefully when I've done with the refactoring you won't need the helper :)

@kristm

Hi @markevans , any update on this feature?
Actually what I had more in mind is to get the absolute file path of a previously uploaded image

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.