Using Custom Image Sizes
-
Just a note for others who might be curious about using custom sized images.
My ‘large’ image size is set to 1024px wide and my email template is 600px wide and with some padding my image size at full width (not mobile version) is 564px wide.
I didn’t like the thought of having to load a large sized image into an email when it was nearly twice as large in both resolution and file size. To modify this plugin for my needs here is what I did:
First I used the function add_image_size to create a custom sized image I wanted to use just for my RSS MailChimp feed (this goes in your themes functions.php file):
/* MailChimp RSS Feed Image Size */ if ( function_exists( 'add_image_size' ) ) { add_image_size( 'mailchimp_featured', 564, 250, true ); //564 pixels wide 200px tall, hard cropped }
You can obviously set the image size to whatever you need in the function above. Whenever you use the add_image_size function you’ll probably have to regenerate your thumbnails for old images. New images will automatically get resized to this new size but if you have issues with image already uploaded not showing up when you’re testing this is probably the issue you’re running into. Just search the plugins directory for “regenerate thumbnails” and there will be many options to use.
Then you just need to edit the ImageChimp file (mb-imagechimp-feed-enhancer.php) file on line 69 (as of time of writing this).
Where it has this:
$img_attr = wp_get_attachment_image_src( $img_id, apply_filters('mb_rss_extend_item_media_image_size','large') );
Replace it with this:
$img_attr = wp_get_attachment_image_src( $img_id, apply_filters('mb_rss_extend_item_media_image_size','mailchimp_featured') );
Or replace the word “large” with the name of the image size you created with the function you place in your functions.php file.
It might be beneficial to add a settings page to this plugin allowing users to set what image size they want the image used on the feed to be or allowing them to set a custom size directly via the plugin.
Just thought somebody else might find this helpful.
-GB
https://www.ads-software.com/plugins/mb-imagechimp-rss-feed-enhancer/
- The topic ‘Using Custom Image Sizes’ is closed to new replies.