[Resolved] Show Featured Image Resolution under sidebar and size with GP Hooks

Home Forums Support [Resolved] Show Featured Image Resolution under sidebar and size with GP Hooks

Home Forums Support Show Featured Image Resolution under sidebar and size with GP Hooks

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #383632
    Ralfs

    How to show Featured images Size and resolution under sidebar with GP hooks? What PHP function I have to use?

    #383645
    Tom
    Lead Developer
    Lead Developer

    I’m not too sure what you mean – any examples?

    #383698
    Ralfs

    For example here – https://puu.sh/xxM4V/2ceeb0c32e.png

    I want to display info about Featured image. I want to use GP Hooks, so I can display the info before sidebar on single post

    #384217
    Tom
    Lead Developer
    Lead Developer

    That would involve some pretty heavy coding.

    I think you would use this function: https://developer.wordpress.org/reference/functions/wp_get_attachment_image_src/

    Check out the examples at the bottom on how to get the height and width etc..

    #384369
    Ralfs

    Hi,
    I did manage to figure it out myself:

    I added this to GP hook:

    <?php 
    if ( has_post_thumbnail() ) {
    	$large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
    	echo 'Resolution: '.$large_image_url[1].'x'.$large_image_url[2];
    }
    ?>

    But I need to know, is this good solution?

    Actually resolving issues is a lot of fun πŸ˜€ Myb I should learn wp development myself. πŸ™‚

    #384398
    Tom
    Lead Developer
    Lead Developer

    That’s perfect πŸ™‚

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.