Comments (5)
Hey @shuuuuun and thanks for opening this suggestion. We've received similar questions to this in the past but since imgix does not support locally-served images, a change like this would be considered out of scope for a library like this. I would be curious to hear more about your use case and how this feature helps to support it. Thanks!
from js-core.
@sherwinski Thanks for your reply!
My use case is as follows.
- I am using the
ix-img
tag fromvue-imgix
.
https://github.com/imgix/vue#basic-use-case
https://github.com/imgix/vue/blob/v2.9.0/src/plugins/vue-imgix/ix-img.tsx - In some places I am using
buildUrlObject
function manually to use srcset.
https://github.com/imgix/vue#buildurlobject
https://github.com/imgix/vue/blob/v2.9.0/src/plugins/vue-imgix/vue-imgix.ts#L47-L70 - They are internally using
ImgixClient._buildURL
. (when protocol is included)
https://github.com/imgix/vue/blob/v2.9.0/src/plugins/vue-imgix/vue-imgix.ts#L76-L83 - The URLs specified for src or function are obtained from the server via API.
- The API response already contains origin(protocol + host).
- The imgix domain is used in the production environment, and localhost in the local development environment.
- While still using the
ix-img
tag, I want to be able to reference images on localhost in the local development environment.- It is complicated to use different
img
tag andix-img
tag depending on the environment or domain.
- It is complicated to use different
I am using vue-imgix in my case, but I think this issue is not limited to that.
I think it always happens when you get an image URL including origin via API and specify it to src through this library.
If there is a way to work around this without changing the library, I would be interested to know.
Thank you.
from js-core.
Hey @shuuuuun, thank you for providing more details and apologies for the delayed follow-up here. To answer each of your questions:
- There isn't an out-of-the-box solution to this issue offered in this library currently. Unfortunately, switching between
img
andix-img
seems to be the best work around at this point. - We have received similar requests in the past to what you are asking for here. From our standpoint, these libraries are primarily focused on serving imgix URLs/images; therefore supporting functionality aside from that feels out of scope from that focus.
Having said that, I will bring this issue up in our next team meeting and see what others think as well. I will update this thread once I have more information.
from js-core.
Hi @shuuuuun,
After discussing it further with the team, we've ultimately decided not to support this request. The reason being that this library is meant to facilitate the reliable construction of URLs tied to the imgix rendering service. By expanding the validation rules, we are losing the ability to guarantee that reliability. And while we generally try to leave wiggle room for developer convenience, doing so in this case to support images not served through imgix feels a bit too out of scope for this project. Apologies and hope you can understand our position.
With that said, I think there is another workaround that you could considering using in your case. Instead of using localhost
in your dev environment, you can use dummy domain such as sherwinski.imgix.local
:
import URLBuilder from '@imgix/js-core';
let ub = new URLBuilder({
domain: process.env.NODE_ENV === 'production' ? 'sherwinski.imgix.net' : 'sherwinski.imgix.local',
});
Then edit your local hosts file so that sherwinski.imgix.local
resolves to localhost
:
# /etc/hosts
127.0.0.1 sherwinski.imgix.local
Hopefully this helps you. I am going to close this issue for now but please feel free to comment back if any other questions come up.
Edit: Assuming you want to specify the port, you will likely need to set up a reverse proxy as the hosts files only handles hostnames.
from js-core.
Thank you for your consideration.
I understand your decision.
In my case, the workaround of switching img and ix-img seems to be a good one.
Editing the local hosts file would be a hassle to share the procedure with other developers, especially if a reverse proxy is required.
Thanks for providing a good service and library.
from js-core.
Related Issues (20)
- Encrypting the origin URL HOT 5
- `buildSrcSet` mutates `params` argument when building either fluid or fixed-width srcset. HOT 2
- A fluid-width srcset is generated when a height is passed HOT 13
- Image has distored boarder when used in <meta></meta> tag HOT 1
- Expires params? HOT 2
- Action Required: Fix Renovate Configuration
- Dependency Dashboard
- Allow different Quality presets for buildSrcSet HOT 3
- Allow configure srcSet DPR generation HOT 3
- Relax js-base64 constraint to `^3.6` HOT 2
- Typescript types for `params` HOT 3
- Do you support Management APIs? HOT 3
- Query parameter values should be URL encoded HOT 10
- Latest @imgix/js-core does not work with Nuxt 3 HOT 4
- host is depracated but... HOT 4
- Ability to define success/failure/processing handlers HOT 1
- Typings HOT 10
- Typescript and `@types/node` should be devDependencies. HOT 2
- Plus-sign in S3 key causes 404 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from js-core.