}
}
- $emailContent = $smarty->template->fetch( 'eval:' . $view );
+ $emailContent = $smarty->template->fetch( 'eval:' . $this->fixImages( $view ) );
$Templates = new GlmDataEmailTemplates( $this->wpdb, $this->config );
$template = $Templates->getEntry( $template );
}
+ public function fixImages( $content )
+ {
+ $dom = new DOMDocument( '1.0', 'UTF-8' );
+ $dom->encoding = 'UTF-8';
+ $test = $dom->loadHTML( $content );
+ $images = $dom->getElementsByTagName( 'img' );
+ foreach ( $images as $image ) {
+ $width = $height = $align = null;
+ if ( $image->hasAttribute( 'class' ) ) {
+ // Is it left or right or center?
+ if ( preg_match( '%alignleft%', $image->getAttribute('class'))) {
+ $align = 'left';
+ }
+ if ( preg_match( '%alignright%', $image->getAttribute('class'))) {
+ $align = 'right';
+ }
+ if ( preg_match( '%aligncenter%', $image->getAttribute('class'))) {
+ $align = 'center';
+ }
+ }
+ switch ( $align ) {
+ case 'left':
+ $image->setAttribute( 'style', 'float: left; margin: 5px;' );
+ break;
+ case 'right':
+ $image->setAttribute( 'style', 'float: right; margin: 5px;' );
+ break;
+ case 'center':
+ $image->setAttribute( 'style', 'display: block; text-align: center; margin: 0 auto;' );
+ break;
+ }
+ }
+ $content = $dom->saveHTML();
+ return $content;
+ }
}