Skip to content

Instantly share code, notes, and snippets.

@scrobbleme
Created April 2, 2020 14:39
Show Gist options
  • Save scrobbleme/0561c09333b74a44d502bcfb9c718f76 to your computer and use it in GitHub Desktop.
Save scrobbleme/0561c09333b74a44d502bcfb9c718f76 to your computer and use it in GitHub Desktop.
Mailpoet: Change column sizes
<?php
/**
* This will replace the default values with new ones, within the rendered content of newsletters
*/
add_filter( 'mailpoet_rendering_post_process', function ( $content ) {
$max_width = 900;
$width_mapping = [
660 => $max_width,
330 => abs( $max_width / 2 ),
220 => abs( $max_width / 3 ),
440 => abs( $max_width / 3 * 2 )
];
foreach ( $width_mapping as $width => $new_width ) {
$content = str_replace( "width=\"$width\"", "width=\"$new_width\"", $content );
$content = str_replace( "width:" . $width . "px", "width:" . $new_width . "px", $content );
$content = str_replace( "max-width:" . $width . "px", "max-width:" . $new_width . "px", $content );
}
return $content;
}, 20, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment