• Resolved Kiran

    (@kiranbhai)


    I am trying to get Attachment file URL and File size in wordpress post. Here by the given loop i am get the file URl but how to Get the file size . Tell me about the loop for attachment file size.

    `<?php
    // Get all PDFs that are attached to this post in the loop
    $pdf_attachments = get_attached_media(‘application/pdf’, get_the_ID());

    // Pull out the first attached PDF (even if there’s only one, the above returns an array)
    $pdf_attachment = key($pdf_attachments);

    // Get the link to the PDF
    $pdf_link = wp_get_attachment_url($pdf_attachment);
    ?>

    in Post:
    <?php echo $pdf_link ?>

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘View the PDF file Size In Post’ is closed to new replies.