Skip to content

Instantly share code, notes, and snippets.

View Pamps's full-sized avatar

Darren Lambert Pamps

View GitHub Profile
@Pamps
Pamps / wp_get_attachment_image_url
Created October 1, 2019 08:01
How to get a WordPress attachment image URL in the required size
Much is made of the WordPress function wp_get_attachment_image_src() which returns an array of data for an attachment image.
But dealing with the array is not alway welcome.
wp_get_attachment_image_url() is your friend here as it returns the URL of the attachment at the desired size.
#$ cat fix-dropbox.sh
#!/bin/bash
# XXX: use at your own risk - do not run without understanding this first!
#exit 1
# safety directory
BACKUP='/tmp/fix-dropbox/'
# TODO: detect or pick manually...
<?php
// Change the image size used for the WooCommerce product gallery image zoom
// 'medium' or 'large' are normally the best options
add_filter( 'woocommerce_gallery_full_size', function( $size ) {
return 'medium';
} );
?>