Closed hacknug closed 4 years ago
Hi @hacknug,
thanks for the request.
Yes it should be possible to disable the automatic filename generation.
After thinking a bit about your request, I have two examples:
If I want to embed an image, which is hosted on imgix
, I can define some additional url parameters to transform/optimize/manipulate the image.
This means, the URL is
https://imgix.com/image.jpg?option1=1&option2=2
and not
https://imgix.com/image.jpg
The image url doesn't contain a dedicated filename in the url. Example for this is: http://lorempixel.com/400/200/sports/1
For example 1, it's possible to extract the filename via a simple regexp, but for example 2, I have no idea how to solve this.
The reason why I have hashed the filename ( based on the Image URL ) is to keep it simple and make sure, that the image name is unique and doesn't overwrite an existing filename, because a filename only isn't unique for me and if I have different sources with the same filename, I have a conflict.
What do you think?
Thanks!
Regards, Marcus
@noxify, good thoughts. For example 2, I would suggest:
400-200-sports-1.jpg
) orCheers, Daniel
Example 1
If I want to embed an image, which is hosted on
imgix
, I can define some additional url parameters to transform/optimize/manipulate the image.This means, the URL is
https://imgix.com/image.jpg?option1=1&option2=2
and not
https://imgix.com/image.jpg
This one I'd probably solve with using URL
and getting its pathname
property. Should be trivial as you mentioned.
Example 2
The image url doesn't contain a dedicated filename in the url. Example for this is: http://lorempixel.com/400/200/sports/1
In this case I was going to say I would do what @dsturm suggested but realized images could be inside an /assets
directory so I'd say:
1.jpg
400/200/sports/1.jpg
(maybe true
by default?)In my case I have a bunch of JSON files with about 1000 image links each, most of which are not unique. What I would like is to be able to download all the files I'm missing and skip whatever's already on my repo. In this project I think I would mind to be able to replicate the sources dir structure.
It would also be cool to be able to specify if I want to force a re-download of everything (false
by default I'd say).
Right now the plugin renames each file using a hash. I think it might be a better idea to allow users to configure this using
options.targetFileName
. This could accept a function that getsimageSource
to allow users to keep the current functionality.By default (when
!options.targetFileName
) it should keep the original file name.