• Hi every one. I need your help.
    I have searching about 2 days and doesn’t get any tutorial.
    I need to know how to display File Size, File Type and dimensions in Attachment page.

    Like this one.

    I take this screen at Media Upload in WP admin Dashboard.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Have a look at the wp_prepare_attachment_for_js function reference in the Codex.

    Thread Starter Herlinhox

    (@herlinhox)

    Thanks for your reply.
    I’m confuse how to use this feature. I want to display a text “File Type : JPG” for example under image in attachment page. Should I use code like this?
    <?php wp_prepare_attachment_for_js(‘type’) ?>

    and displaying text “Dimensions : 1980×1080”. use this code?
    <?php wp_prepare_attachment_for_js(‘width’,’height’) ?>

    I don’t see anything being displayed under attachment image.

    Help me please Mr Richard Aber

    Thread Starter Herlinhox

    (@herlinhox)

    Anyone please?
    I need this features

    This function does not to output the attachment details, it retrieves the attachment details.

    You would need to assign the return data of the function to a PHP variable, then output the specific elements you need from that variable.

    You could use the wp_prepare_attachment_for_js function like this overly-simplified example…

    // retrieve the attachment data and assign to variable
    $attachment_data = wp_prepare_attachment_for_js();  
    
    // output the file size
    echo '<p>File Size - ' . $attachment_data['filesize'] . '</p>';  
    
    // output the file type
    echo '<p>File Type - ' . $attachment_data['subtype'] . '</p>';  
    
    // output the dimensions
    echo '<p>Dimensions - ' . $attachment_data['width'] . ' by ' . $attachment_data['height'] . '</p>';
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to Display Attachment File type, File size and Dimensions in Attachment Page’ is closed to new replies.