Khandaker Toihidul Islam
Front-end Developer
React Js | Javascript | HTML | CSS | Bootstrap | Wordpress | PHP | Mysql

WordPress get attachment properties

$thumbnail = wp_get_attachment_image_url( $attachmentId, 'my-custom-size' );
$original = wp_get_attachment_image_url( $attachmentId, 'full' );
$square = wp_get_attachment_image_url( $attachmentId, [600, 600] );
$image_attributes = wp_get_attachment_image_src( $attachment_id = 8 );
if ( $image_attributes ) : ?>
    <img src="<?php echo $image_attributes[0]; ?>" width="<?php echo $image_attributes[1]; ?>" height="<?php echo $image_attributes[2]; ?>" />
<?php endif; ?>

You may also like...