-
Notifications
You must be signed in to change notification settings - Fork 20
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
Wrap large images #46
Comments
Adding a |
Did some testing in one of work's network sites.
Default WordPress image code:
What works in multiple email viewings:
Suggestion of fixThis could be at a falcon level, but my gut says that it should be at a p2 level - where images are selected, they should not have the height set in them. And the extra style tag should be added. This could be done at a falcon leve using regex but i'm debating if thats really the right place for the solution. @rmccue thoughts? let me know if you want a copy of the test emails + posts. |
We fixed this with the following: /**
* Set the max-width, and remove height values of images before the content gets email to everyone.
*
* It solves the problem where images are wider than the window space
* in emails and thus force the email to be extra wide.
*
* @param string $content
*
* @return string $content
*/
function image_width_filter( $content = '' ) {
if ( ! preg_match_all( '/<img [^>]+>/', $content, $matches ) ) {
return $content;
}
foreach( $matches[0] as $image ) {
$original = $image;
if ( false !== strpos( $image, ' height=' ) ) {
$image = preg_replace( '/ height="([0-9]+)"/', ' height=""', $image );
}
$image = str_replace( '<img ', '<img style="max-width:100%; height:auto;" ', $image );
$content = str_replace( $original, $image, $content );
}
return $content;
}
add_filter( 'falcon.connector.wordpress.post_content_html', 'image_width_filter' );
add_filter( 'falcon.connector.wordpress.comment_content_html', 'image_width_filter' ); Yet to be determined whether this should be added to Falcon as well. Probably, is my thinking. |
100% add to falcon! |
We should work out how to style images so they don't break emails.
The text was updated successfully, but these errors were encountered: