-
Notifications
You must be signed in to change notification settings - Fork 760
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
[Feature] Image plugin #1130
Comments
@tannerlinsley is there interest in adding an image plugin to React Static? If so, I can look into it |
Yes there is. I'll do my best to outline some of the requirements that said plugin would need, but we'll most definitely need more discussion to happen around it.
I'm sure there's even more we need to discuss, but I think this is a good start. |
Thank you for all the information! Based on the information you provided, my initial thoughts on a potential structure for the image plugin are below. From a user's perspective, I think the plugin can be split into a few parts:
I considered whether the plugin should be utilized via configuration or programmatically. I think that users will have a wide range of requirements as to how they would like to transform images. As a result, I think that a programmatic approach could work well, if you think it fits with the style and simplicity of React Static's approach. Alternatively, we could consider plugins. Here's a quick example of what I'm thinking... static.config.js
If transform callback is not provided, plugin will set reasonable defaults (or user could set defaults), such as generating a placeholder image and setting image to lazy load. Details would change slightly if importing a folder since it'd return an array. Meanwhile, plugin provides its own version of useRouteData that transforms the object into a ReactStaticImage object. Alternatively, we could use a separate hook instead of replacing useRouteData. To use: blog.js
Thoughts? |
@tannerlinsley please see https://github.com/dev-rsilver/plugin-react-static-images for a start to this plugin. Implementation is slightly different from what I outlined in the previous message. Currently implements:
The ImageComponent is designed to be a drop-in replacement for img elements with respect to CSS styling. To test (note that instructions are for testing only, not production):
Feedback would be welcomed, even if you would like to move in another direction. |
Any plans to introduce an image plugin to do things like lazy load images?
I found an old discussion #309 about plugins, but it, and the referenced project, have been closed.
The text was updated successfully, but these errors were encountered: