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
Don't use absolute URL's as resize_image's output #1245
Comments
Some possible ways to resolve this backwards-compatibly:
|
I'm running into this limitation myself. I'd love it if
For instance, if the width/height were returned properly, then we wouldn't need to do any kind of song and dance with |
Yep it would be a nice improvement. I don't know if it's going to make it to 0.14 though - already a lot of changes in there going on for i18n |
Completely fair, I can work around the above limitations for now, as long as this is on the horizon for future work. Thanks for your hard work on Zola! |
There's been a few change to |
Has this issue really been addressed by the changes in 0.14? As far as I can tell, the returned object contains two relevant fields: I think what would be needed to address this issue is a field with an absolute URL without explicit domain name or protocol, so |
Note to anyone looking for a workaround: Tera has the |
It could be added or the workaround with the Tera filters documented |
In an attempt to not make this a +1-style comment.. I agree that this is a feature that should be supported without workarounds. I also don't think we need to break backwards compatibility to allow for this use case. just to establish some terms here:
I think what we can add here is an additional attribute the name doesn't need to be |
I've crudely implemented the above: syphoxy@50f68ef looking for feedback. |
I think you can just apply the Tera workaround above in the codebase directly using https://doc.rust-lang.org/std/primitive.str.html#method.trim_start_matches with the base_url as a pattern? |
that really strikes me as a hack as opposed to properly managing URLs and paths. it would also inextricably link the static asset location with the public asset location forever. |
the more I think about this the more I realize that maybe the original suggestion, a global flag in just to clarify my use case: my original use case was that I wanted to load the static site generated from disk but realizing it used URLs instead of relative paths, I reached for something like darkhttpd for a quick solution. that works but lots of things broke because it was using my FQDN and not localhost:8080 (or similar). not great (my idea): a change like this where I can instruct resize_image to give me a full path, instead of a URL, does fix this but it also implies that a change like this would infect every aspect of Zola that generates a URL in the future. do we now provide if we viewed it as 2 scenarios:
for case 1 you can always set the for case 2 there's really nothing to be done right now except hardcode it in your templates. |
Bug Report
Environment
Zola version: 0.12
Expected Behavior
resize_image
would output URLs that work wherever the site happens to be deployed at.Current Behavior
resize_image
outputs URLs that have thebase_url
hardcoded in, making it impossible to deploy into a preview/staging environment that has a different domain name, without the images breaking.Step to reproduce
<img src="{{ resize_image(path="some_image.jpg", width=600, height=600, op='fill') | safe }}">
in some file in contents.base_url
would suggest.The text was updated successfully, but these errors were encountered: