How to add additional gallery thumbnail sizes in WordPress

Create uniquely resized image thumbnails for use in content pages, blog posts, landing pages and galleries, speeding up the loading speed of your WordPress website

For many of us, the standard set of gallery sizes in WordPress aren’t enough and for many, they create their own set of issues. In turn, for any knowledgable WordPress developer, controlling what sizes are being created every time you upload an image is crucial for a proper, fast, and well-performing website. Below you will find a snippet that we’ve created for one of our clients, which you need to add to functions.php in order for it to work. Naturally, if you aren’t adding this prior to developing your website and uploading new media, you will have to regenerate all the thumbnails – easily done by the Regenerate Thumbnails plugin, which you can download & install on your WordPress site for free.

/** Gallery Sizes */

add_image_size(‘images-medium’, 450, 450, array(‘center’, ‘center’));
add_image_size(‘gallery-small’, 480, 300, array(‘center’, ‘center’));
add_image_size(‘gallery-medium’, 720, 405, array(‘center’, ‘center’));
add_image_size(‘gallery-thumb’, 500, 350, true );
add_image_size(‘woocommerce_single_resized’, 1000, 1000, true );

/** Media Gallery Sizes Add-on */

add_filter( ‘image_size_names_choose’, ‘my_custom_sizes’ );

function my_custom_sizes( $sizes ) {
return array_merge( $sizes, array(
‘gallery-small’ => __( ‘Gallery Medium Cropped’ ),
‘gallery-medium’ => __( ‘Gallery Medium’ ),
) );
}

In this case, we’re adding 5 additional thumbnail sizes that we need for theme placements for our client’s website. These items are catered to a 1440px wide design grid size we’re using, allowing us to fill out the pages perfectly, all without adding too much weight to them. Naturally, it would be a great idea to use the <picture> element within the template’s design or ACF (Advanced Custom Forms). This will give you more leeway in terms of loading image sizes that fit each screen, allowing you to load smaller and less heavy imagery. In turn, this will undoubtedly speed up your site, as it stops loading large thumbnail sizes, albeit filling out the content area real estate perfectly. Below you will find an example of what is done on EV Car Scene, one of the websites we manage & develop.

EV Car Scene - Custom Sized Thumbnails For Use In Content Pages
EV Car Scene – Custom Sized Thumbnails For Use In Content Pages
DISCLAIMER: Please use the code, advice, and information presented on this website with caution. Nucleus J.D.O.O, or any of its employees, cannot be held responsible for any damages that this code might cause. We always try to update the code shown on our website, but we cannot guarantee its functionality with various themes, templates, or coding. Please ensure that you test each code thoroughly in order to use it safely.

 

How To Send A CC or BCC of Customer E-Mails in WooCommerce To Other E-Mail Address

For those running WooCommerce either for themselves or for their clients, the question we’re about to answer below comes into view quite often. Basically, most of our  clients want to have this option. After all, checking the e-mails that are sent to your customers is a great way to further troubleshoot any issues, but also, to ensure that  all the e-mails get sent out and that they contain all the necessary information. That’s why the code snippet added below will help you CC or BCC your customer e-mails to another e-mail address, preferably your own. Here’s the code below.

/** Send out a copy of WooCommerce e-mails to another address **/

add_filter( ‘woocommerce_email_headers’, ‘woocommerce_email_headers_nucleusmarketing’, 10, 4 );
function woocommerce_email_headers_nucleusmarketing( $header, $email_id, $email_for_obj, $email_class ) {
// Bcc this email address to *all* WooCommerce emails.
$header .= ‘Bcc: accounting@nucleusmarketing.org’ . “\r\n”;

// Add another address to the Order Completed emails only.
if ( ‘customer_completed_order’ == $email_id ) {
$header .= ‘Bcc: accounting@nucleusmarketing.org’ . “\r\n”;
}

return $header;
}

While WooCommerce doesn’t provide this feature out of the box, the above solution will simply create a BCC to your accounting and/or any e-mail address you want the customer confirmation e-mails (eg. processing order, completed order, etc.) to go to. It’s easy, works with the current WordPress 5.6 and WooCommerce 4.8.0 versions. Please free to send us a note if you find this code not working, we’ll appreciate it.

CloudFlare Launches Automatic Platform Optimization For WordPress

Today, Cloudflare launched Cloudflare APO (Automatic Platform Optimization). It’s a solution that allows (for now) WordPress and WooCommerce users to enhance their loading speeds, see lower TTFB (Time To First Byte) timings and make their websites run better. Since we’re a webdev and marketing agency dedicated to both increasing the lowering speeds and improving the overall usability of our client’s websites, we are looking forward to implementing these solutions to each of our clients that use Cloudflare. That being said, we’re undertaking a testing batch next week to confirm the increases in performance on some of our own, but also, on some of our client’s websites as well. However, since most of our websites are already greatly optimized for both speed and performance, we’re looking to see what results we get. Here’s a short rundown of the Cloudflare APO (Automatic Platform Optimization) right below:

Today, we are announcing a new service to serve more than just the static content of your website with the Automatic Platform Optimization (APO) service. With this launch, we are supporting WordPress, the most popular website hosting solution serving 38% of all websites. Our testing, as detailed below, showed a 72% reduction in Time to First Byte (TTFB), 23% reduction to First Contentful Paint, and 13% reduction in Speed Index for desktop users at the 90th percentile, by serving nearly all of your website’s content from Cloudflare’s network. This means visitors to your website see not only the first content sooner but all content more quickly.

With Automatic Platform Optimization for WordPress, your customers won’t suffer any slowness caused by common issues like shared hosting congestion, slow database lookups, or misbehaving plugins. This service is now available for anyone using WordPress. It costs $5/month for customers on our Free plan and is included, at no additional cost, in our Professional, Business, and Enterprise plans. No usage fees, no surprises, just speed.

We’ll get more in-depth into the details and the nitty-gritty of how this service works & affects loading speeds for the websites we run for our clients. In the meantime, if you’re interested in adding Cloudflare to your website or you need it optimized or rebuilt, please contact us right away. Our sales team will give you an exact quote and we will ensure to bring you up to speed on all current best web design and web optimization practices. Certainly, you can also use our consultation services and see what can be done to make your website go faster, bounce rate is lower, or increase overall sales. We can do it for you!