Skip to content

Commit

Permalink
fix: image size from template
Browse files Browse the repository at this point in the history
For some reason the sizeSlug is not passed, but Gutenberg also adds a className to image block.
  • Loading branch information
adekbadek committed Apr 14, 2020
1 parent 1c7fbd3 commit 07bc7ed
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions includes/class-newspack-newsletters-renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,13 @@ private static function render_mjml_component( $block, $is_in_column = false, $i
if ( 'thumbnail' == $attrs['sizeSlug'] ) {
$img_attrs['width'] = '150px';
}
} elseif ( isset( $attrs['className'] ) ) {
if ( 'size-medium' == $attrs['className'] ) {
$img_attrs['width'] = '300px';
}
if ( 'size-thumbnail' == $attrs['className'] ) {
$img_attrs['width'] = '150px';
}
}
if ( isset( $attrs['width'] ) ) {
$img_attrs['width'] = $attrs['width'] . 'px';
Expand Down
2 changes: 1 addition & 1 deletion includes/class-newspack-newsletters.php
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ public static function template_token_replacement( $content, $extra = [] ) {
);

$logo_block = $logo ? sprintf(
'<!-- wp:image {"align":"center","id":%s,"sizeSlug":"thumbnail"} --><figure class="wp-block-image aligncenter"><img src="%s" alt="%s" class="wp-image-%s" /></figure><!-- /wp:image -->',
'<!-- wp:image {"align":"center","id":%s,"sizeSlug":"thumbnail"} --><figure class="wp-block-image aligncenter size-thumbnail"><img src="%s" alt="%s" class="wp-image-%s" /></figure><!-- /wp:image -->',
$custom_logo_id,
$logo,
$sitename,
Expand Down

0 comments on commit 07bc7ed

Please sign in to comment.