Skip to content

Instantly share code, notes, and snippets.

@RadGH
Created November 16, 2015 17:45
Show Gist options
  • Save RadGH/03a03b95d7d4aa919ed7 to your computer and use it in GitHub Desktop.
Save RadGH/03a03b95d7d4aa919ed7 to your computer and use it in GitHub Desktop.
define & use custom image sizes
<?php
// $src = wp_get_attachment_image_src( $attachment_id, 'store-archive' );
// $src[0] = "http://.../uploads/my_image-240x350.jpg"
// $src[1] = 240
// $src[2] = 350
add_action( 'after_setup_theme', 'ld_theme_image_sizes' );
function ld_theme_image_sizes() {
// archive pages
add_image_size( 'store-archive', 240, 350, 1 );
// single product pages, the main image
add_image_size( 'store-singular', 520, 700, 1 );
// single product pages, the thumbnails used below the main image
add_image_size( 'store-gallery-thumb', 100, 150, 1 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment