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

Invalid URL created when used with other plugin for image resizing. #137

Open
NigelRel3 opened this issue Feb 25, 2024 · 0 comments
Open

Comments

@NigelRel3
Copy link

We use Tachyon for image scaling and this will sometimes add parameters to the image, something like image.webp?resize=10x10.

In the admin site, we found the image was sometimes not displayed after upgrading to a newer node version of the plugin. After some debugging it was found that the url being created in the render_field() method in this plugin was just adding ?v=_hash_ to the end of the url giving a url of image.webp?resize=10x10?v=_hash_. If you take the url and paste it into a browser it fails to load, change the second ? to an & and the image loads. This is down to the second ? being treated as part of the previous parameter rather than as a separate one (according to https://stackoverflow.com/questions/2924160/is-it-valid-to-have-more-than-one-question-mark-in-a-url)

I would think that a simple fix would be to change to code to check for a ? before just appending the v parameter and this should solve the problem and also ensure it's added correctly. Something along the lines of

            // url exists
            if ($url) {
                $url = $url[0] . (strpos($url[0], '?') === false ? '?v=' : '&v=') . md5(get_the_date($image_id));
            }

If I create a PR and add this, is this likely to be added soonish, or should I create a temporary work around to keep the sites working properly.

Thanks
Nigel

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

No branches or pull requests

1 participant