Last active
April 24, 2017 06:19
-
-
Save AlexWebLab/58035c8fbfe349fe6ac3b2741ab37b32 to your computer and use it in GitHub Desktop.
Resizing and showing images from ACF in WordPress theme development for page load performance optimisation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'after_setup_theme', 'custom_image_sizes' ); | |
function custom_image_sizes() { | |
add_image_size( 'image-1400px-wide', 1400 ); // 1400 pixels wide (and unlimited height) | |
add_image_size( 'image-700px-wide', 700 ); // 700 pixels wide (and unlimited height) | |
add_image_size( 'image-350px-wide', 350 ); // 350 pixels wide (and unlimited height) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php $image_src = wp_get_attachment_image_src( get_field('image_ID'), 'image-700px-wide' ); ?> | |
<!-- THIS WAY THE USER IS FREE TO UPLOAD AN IMAGE OF ANY SIZE (e.g.: from the smartphone) --> | |
<img src="<?php echo $image[0]; ?>" class="img-responsive product-image" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment