-
Notifications
You must be signed in to change notification settings - Fork 793
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
Load Photon resized images in gallery widget #3680
Load Photon resized images in gallery widget #3680
Conversation
@@ -21,8 +21,7 @@ public function __construct( $attachment_image, $needs_attachment_link, $graysca | |||
$this->orig_file = wp_get_attachment_url( $this->image->ID ); | |||
$this->link = $needs_attachment_link ? get_attachment_link( $this->image->ID ) : $this->orig_file; | |||
|
|||
$this->img_src = add_query_arg( array( 'w' => $this->image->width, 'h' => $this->image->height, 'crop' => true ), $this->orig_file ); | |||
|
|||
$this->img_src = jetpack_photon_url( $this->orig_file, array( 'resize' => sprintf( '%s,%s', $this->image->width, $this->image->height ) ) ); |
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.
If you're using sprintf
here, then those dimensions should probably be cast to decimal/numbers (%d
), rather than strings (%s
).
These changes make sense to me. @jeherve, can you recall any time something has gone wrong or someone has complained when we've photonizing image URLs? |
That shouldn't be a problem. We're photonizing image URLs in multiple other areas of the plugin (like Related Posts thumbnails for example), and it's usually not an issue as long as we have a good reason to do so. |
This seems ready to me. @samhotchkiss? |
@@ -253,7 +253,7 @@ public function slideshow_widget( $args, $instance ) { | |||
|
|||
foreach ( $instance['attachments'] as $attachment ) { | |||
$attachment_image_src = wp_get_attachment_image_src( $attachment->ID, 'full' ); | |||
$attachment_image_src = $attachment_image_src[0]; // [url, width, height] | |||
$attachment_image_src = jetpack_photon_url( $attachment_image_src[0], array( 'w' => $this->_instance_width ) ); // [url, width, height] |
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.
Should we have $this->_instance_width
going through the gallery_widget_content_width
filter, like it's done for the Gallery widget?
cc @mdawaffe
This seems to work well in my tests. Merging. |
…size resulted in bad things. Switching back to the original params, albeit passing it through `jetpack_photon_url()` now as the newer Jetpack code did. Context: #3680 See: https://[private link] Merges r152553-wpcom.
Fixes #1186 .
Changes proposed in this Pull Request:
grunt jshint
before to commit your changes. It will allow you to detect errors in Javascript files.