-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split remote fecthing in resources.Get
into its own function
#9285
Comments
resources.Fetch
for remote resources and limit resources.Get
to local assetsresources.Get
into its own function?
Voting for |
@regisphilibert assuming you control the code, you can do
There are no accidents in the above? And you would do something similar if you would use the new |
Yes I would if the method was not renamed, but if it is renamed, then I'll stick with the original test (is there a local resource at the passed location?). |
Hmm ... The vote is clear. |
This was bit like a trial, with the prosecution presenting evidence, and the jury voting to convict. I'm not sure the defense attorney was able to present their case. |
@jmooring what did you vote? |
|
Yea, I'm still not sure ... One of Hugo's "problems" is a little too many moving parts. What I like about the |
... what about adding a |
I'm focusing on the second part of that sentence. This functionality is extremely important as it makes Hugo capable of grabbing anything remote, (And yes API is what I'm mostly concerned about, and what I predict will make 80% of that feature's uses case), so let's make it stand out. But also I think a function which grab a local file from the dedicated asset directory should not be the same as the one which give you access to the unlimited internet. |
... what about adding a resources.GetLocal function? That sounds like a big breaking change. |
I'm a big fan of readme-driven development, because it forces you to explain it to someone before you do it. I have a docs PR in progress for content-management/image-processing/index.md... Image ResourceTo process an image, you must access the image as either a page resource or a global resource. Image as Page ResourceA page resource is a file within a [page bundle]. A page bundle is a directory with an
To access an image as a page resource:
Image as Global ResourceA global resource is a file:
To access a local image as a global resource:
To access a remote image as a global resource:
|
Not from Hugo 0.90 :-) |
Oh so you mean a That seems confusing, but it's in your hand, I'm really grateful for that new feature! It's a Huge leap for Hugo, I think we should make it clear it's not limited to images, fonts etc... but... I'll stop now ;) |
How would adding a new function be a breaking change? |
@regisphilibert never mind, I was just blabbering; this was a rather breaking change when adding resources.Get -- I will add a GetRemote and get that out some time this weak. @jmooring I can also add the adjustment we discussed re this, if you have not already implemented it... |
resources.Get
into its own function?resources.Get
into its own function
In Hugo 0.89 we added remote support to `resources.Get`. In hindsight that was not a great idea, as a poll from many Hugo users showed. See Issue gohugoio#9285 for more details. After this commit `resources.Get` only supports local resource lookups. If you want to support both, you need to use a construct similar to: Also improve some option case handling. ``` {{ resource := "" }} {{ if (urls.Parse $url).IsAbs }} {{ $resource = resources.GetRemote $url }} {{ else }} {{ $resource = resources.Get $url }} {{ end }} ``` Fixes gohugoio#9285 Fixes gohugoio#9296
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I'm sorry to bring this up so late, it did not occur to me before upgrading but I'm having second thought about this functionnality sharing its name with a very commonly used method.
Many people are using CMS, with markdown images added to the body content. We then try and improve generated images with render hooks.
This meant a simple
with resources.Get .Destination
to find the local image, and if not found use the existing.Destination
. But withresources.Get
going "remote capable", now any URL passed throughresource.Get
is a resource created and potentially processed by Hugo.I envision several problems. A website publishing its image on imgix, and relying on the imgix server to transform image like
https://xxxx.imgix.net/home_slide_kayak.jpg?auto=format&ch=Width,DPR&q=95&w=2000
. The latter being accidentally passed throughresource.Get
would trigger an uneccessary fetch and transformation.Not that many use case comes to mind beside
render-hooks
, and it's of course something we can "guard" by looking at the passed string and making sure it's relative.But I'm opening a discussion here, in case other use cases could fall into the same problem. I do think, a bit late sorry again, that something as powerfull, could have its own name/method and its own entry in the documentation site, rather than share it with another commonly used one. It would also ensure that we have 100% control on what is locally "got" and/or "remotely" fetched.
We have
Adding a fourth one,
resources.Fetch
or other wouldn't hurt.The text was updated successfully, but these errors were encountered: