Skip to content

Instantly share code, notes, and snippets.

@mwender
Last active December 13, 2018 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwender/4b3fb12367f45eaca565fcd2c8b35e82 to your computer and use it in GitHub Desktop.
Save mwender/4b3fb12367f45eaca565fcd2c8b35e82 to your computer and use it in GitHub Desktop.
Filter for displaying a HiDPI image in the header of the WP HTML Email plugin for WordPress
<?php
namespace Functions\htmlemail;
/**
* Filters the WP HTML Email header
*
* The following works with a graphic sized at 1200x300px. The
* final display is shown @2X pixel density as the image is
* scaled down to 600x150px.
*
* @param string $headertext The headertext
*
* @return string Filtered email header
*/
function email_header( $headertext ){
$haet_mail_options = get_option('haet_mail_theme_options');
if (!empty($haet_mail_options)) {
foreach ($haet_mail_options as $key => $option)
$options[$key] = $option;
}
if( !empty( $options['headerimg'] ) )
$headertext = '<a href="' . get_home_url() . '"><img src="' . $options['headerimg'] . '" width="600" height="150" style="width: 600px; height: 150px;" alt="' . get_bloginfo( 'name' ) . '"></a>';
return $headertext;
}
add_filter( 'haet_mail_header', __NAMESPACE__ . '\\email_header' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment