Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wp_get_attachment_image_src() accepts built-in sizes such as thumbnail, medium, large or full.
- // copied from the Codex
- // https://codex.wordpress.org/Function_Reference/add_image_size
- if ( function_exists( 'add_image_size' ) ) {
- add_image_size( 'category-thumb', 300, 9999 ); //300 pixels wide (and unlimited height)
- add_image_size( 'homepage-thumb', 220, 180, true ); //(cropped)
- }
- $image_attributes = wp_get_attachment_image_src( 28, 'category-thumb' );
- var_dump($image_attributes);
- You will notice that the image returned is (an appromixation of) 300x9999-- that is 300 wide by whatever height scales correctly.
Advertisement
Add Comment
Please, Sign In to add comment