-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Refactor: Update getimagesize() Function to Accept Image Paths Instead of URLs #226
base: main
Are you sure you want to change the base?
Conversation
@ArchanRD Thank you for this contribution! Maybe I'm missing something, but why not make the change further up the chain of functionality like here, so that the |
…n a single variable" This reverts commit 00fbae6.
Hey @possumbilities, I tried to do that but I found that the image_url is comming from |
I have simplified the implementation a bit, so it's essentially a one liner change ( but GH is showing it a bit differently though ). |
@@ -1125,10 +1125,11 @@ public function license_html_rdfa( $deed_url, $license_name, $image_url, | |||
$title_work, $is_singular, $attribute_url, | |||
$attribute_text, $source_work_url, | |||
$extra_permissions_url, $additional_attribution_txt, $title, $title_url, $author, $author_url ) { | |||
list($img_width, $img_height) = getimagesize( $image_url ); | |||
$lazy = function_exists('wp_lazy_loading_enabled') && wp_lazy_loading_enabled('img', 'license_html_rdfa'); | |||
$image_path = str_replace( CCPLUGIN__URL, CCPLUGIN__DIR, $image_url ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the two global variables here should be properly escaped. The value of $image_url is already escaped in its definition further up in the file, but the use of these two globals here doesn't provide them as escaped values.
Fixes
Fixes #187 by @brylie
Description
The function
getimagesize()
takes image as parameter and returns the image size i.e height and width. In this PR, we replace image url with image path to fix this issue.Technical details
This issue doesn't occur everytime, however in some cases when a website:
the image may not be accessible through the image url, hence calling the
getimagesize()
with image url may not work always. Also everytimegetimagesize()
function is called, the server sends a request to load the image increasing execution time. Hence I've chosen to pass image path instead of image url ingetimagesize()
. This solution handles the above 2 cases as well as addresses the performace issue of the code.Tests
As described above, this situation doesn't always occur, so it may be difficult to test.
Checklist
Update index.md
).main
ormaster
).visible errors.
Developer Certificate of Origin
For the purposes of this DCO, "license" is equivalent to "license or public domain dedication," and "open source license" is equivalent to "open content license or public domain dedication."
Developer Certificate of Origin