Skip to content
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

Support relative paths for network image rendering #532

Merged
merged 3 commits into from
Feb 9, 2021

Conversation

erickok
Copy link
Collaborator

@erickok erickok commented Feb 8, 2021

Implemented relative paths in image loading via custom image render API.

Whilst this still require modest manual work (by setting the custom image render), it solves this fairly common use case with little effort from users, and still offering much flexibility.

            // Install a custum render for all relative paths that start with the /wiki prefix
            (attr, _) => attr["src"] != null && attr["src"].startsWith("/wiki"):
                networkImageRender(baseUrl: "https://upload.wikimedia.org"),

Fixes #153 and closes #146

Copy link
Collaborator

@tneotia tneotia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Simple but effective.

Copy link
Collaborator

@ryan-berger ryan-berger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally think this should be a wrapper around the networkImageRender. I'm open to being persuaded otherwise

lib/image_render.dart Outdated Show resolved Hide resolved
This is useful to apply a base url, but also could be used to swap domains or force an https schema
@tneotia
Copy link
Collaborator

tneotia commented Feb 8, 2021

@erickok with this change can you also update the readme and document this property?

@erickok
Copy link
Collaborator Author

erickok commented Feb 9, 2021

I updated the documentation too.

@ryan-berger ryan-berger merged commit 1c51d62 into Sub6Resources:master Feb 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Relative url addresses in <a> and <img> support
3 participants