Skip to content

Commit

Permalink
remove max-width="100%" for maximum compatibility in Outlook
Browse files Browse the repository at this point in the history
  • Loading branch information
picocodes committed Jan 1, 2025
1 parent b683fcb commit cd2c861
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
31 changes: 31 additions & 0 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2187,3 +2187,34 @@ function noptin_string_to_timestamp( $time_string, $from_timestamp = null ) {

return $next_timestamp;
}

/**
* Returns the smallest registered image size that is at least 150px wide.
*
* @since 3.4.0
* @return string Image size name
*/
function noptin_get_smallest_acceptable_image_size( $minimum_width = 150 ) {
static $smallest_size_cache = array();

if ( isset( $smallest_size_cache[ $minimum_width ] ) ) {
return $smallest_size_cache[ $minimum_width ];
}

$smallest_width = PHP_INT_MAX;
$smallest_size = 'full';

// Find smallest width >= 150px.
foreach ( wp_get_registered_image_subsizes() as $size => $size_data ) {
$width = absint( $size_data['width'] );

if ( $width >= $minimum_width && $width < $smallest_width ) {
$smallest_width = $width;
$smallest_size = $size;
}
}

$smallest_size_cache[ $minimum_width ] = $smallest_size;

return $smallest_size;
}
2 changes: 1 addition & 1 deletion templates/post-digests/email-posts-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<?php if ( has_post_thumbnail( $campaign_post ) ) : ?>
<td class="d-xs-block" width="150" style="width:150px; padding: 0;">
<a href="<?php echo esc_url( get_permalink( $campaign_post ) ); ?>" style="display: block;" target="_blank">
<img src="<?php echo esc_url( get_the_post_thumbnail_url( $campaign_post, 'thumbnail' ) ); ?>" alt="<?php echo esc_attr( get_the_title( $campaign_post ) ); ?>" style="width: 150px; max-width: 100%; height: auto; margin: auto; display: block;">
<img src="<?php echo esc_url( get_the_post_thumbnail_url( $campaign_post, 'thumbnail' ) ); ?>" alt="<?php echo esc_attr( get_the_title( $campaign_post ) ); ?>" style="width: 150px; height: auto; margin: auto; display: block;">
</a>
</td>
<?php endif; ?>
Expand Down

0 comments on commit cd2c861

Please sign in to comment.