We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Is your feature request related to a problem? Please describe. I'm always frustrated when [...] :) I be forced to use external Services.
Describe the solution you'd like Respect the ImageScale setting available in Gutenberg Editor
Describe alternatives you've considered see diff
--- a/wp-content/plugins/newspack-blocks/includes/class-newspack-blocks.php +++ b/wp-content/plugins/newspack-blocks/includes/class-newspack-blocks.php @@ -413,7 +413,7 @@ class Newspack_Blocks { * * @return string Returns the thumbnail key to use. */ - public static function image_size_for_orientation( $orientation = 'landscape' ) { + public static function image_size_for_orientation( $orientation = 'landscape', $scale = false ) { $sizes = array( 'landscape' => array( 'large' => array( @@ -469,7 +469,23 @@ class Newspack_Blocks { 200, ), ), - ); + ); + + if ($scale) { + + $scale = (intval($scale) - 1); + $candidates = array_reverse(array_keys($sizes[ $orientation ])); + + $key = $candidates[$scale]; + $attachment = wp_get_attachment_image_src( + get_post_thumbnail_id( get_the_ID() ), + 'newspack-article-block-' . $orientation . '-' . $key + ); + + if ( ! empty( $attachment )) { + return 'newspack-article-block-' . $orientation . '-' . $key; + } + } foreach ( $sizes[ $orientation ] as $key => $dimensions ) { $attachment = wp_get_attachment_image_src( --- a/wp-content/plugins/newspack-blocks/src/blocks/homepage-articles/templates/article.php +++ b/wp-content/plugins/newspack-blocks/src/blocks/homepage-articles/templates/article.php @@ -32,8 +32,8 @@ call_user_func( $styles = 'min-height: ' . $attributes['minHeight'] . 'vh; padding-top: ' . ( $attributes['minHeight'] / 5 ) . 'vh;'; } $image_size = 'newspack-article-block-uncropped'; - if ( has_post_thumbnail() && 'uncropped' !== $attributes['imageShape'] ) { - $image_size = Newspack_Blocks::image_size_for_orientation( $attributes['imageShape'] ); + if ( has_post_thumbnail() && 'uncropped' !== $attributes['imageShape'] ) { + $image_size = Newspack_Blocks::image_size_for_orientation( $attributes['imageShape'], $attributes['imageScale'] ); } $thumbnail_args = array( 'data-hero-candidate' => true,
(Sorry for the wrong indent - I'm a python developer and do not find which code style you are using.)
I think the Homepage-Articles should respect an explicitly set ImageScale. This can also be the source of further computation at photon.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Is your feature request related to a problem? Please describe.
I'm always frustrated when [...] :) I be forced to use external Services.
Describe the solution you'd like
Respect the ImageScale setting available in Gutenberg Editor
Describe alternatives you've considered
see diff
(Sorry for the wrong indent - I'm a python developer and do not find which code style you are using.)
I think the Homepage-Articles should respect an explicitly set ImageScale. This can also be the source of further computation at photon.
The text was updated successfully, but these errors were encountered: