Hi, Can anyone please help me to display image properties (like- image type png/jpg, image size, image weight etc) for wordpress. In details: User will upload an image in wordpress (from backend) post using featured image area and wordpress post page (front end) will display the image size, image type, image weight etc. Thanks!
Try this code: function my_display_featured_image(){global $post; $thumbnail_id = get_post_thumbnail_id($post->ID); $thumbnail_details = get_posts(array('p'=> $thumbnail_id,'post_type'=>'attachment')); $thumbnail_src = wp_get_attachment_image_src( $thumbnail_id,'full'); $thumbnail_width = $thumbnail_src[1]; if($thumbnail_src && isset($thumbnail_src[0])){ echo '<div class="featured-image';if(!empty( $thumbnail_details[0]->post_excerpt )) echo ' wp-caption'; echo '" style="max-width: '. $thumbnail_width .'px;">';if(!empty( $thumbnail_details[0]->post_excerpt )){ echo '<p class="featured-image-caption">'; echo $thumbnail_details[0]->post_excerpt; echo '</p>';} the_post_thumbnail( $post->ID ); echo '</div>';}} PHP:
Hi you can use <ul> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID ); $attachments = get_posts( $args ); if ( $attachments ) { foreach ( $attachments as $attachment ) { echo '<li>'; echo wp_get_attachment_image( $attachment->ID, 'full' ); echo '<p>'; echo apply_filters( 'the_title', $attachment->post_title ); echo '</p></li>'; } } endwhile; endif; ?> </ul>
Use this function http://codex.wordpress.org/Function_Reference/get_post_thumbnail_id , it will return array containing ID, title..etc, there is example on that page. This works for featured images (as you explained)