WordPress.org

Ready to get started?Download WordPress

Forums

attachment_submitbox_metadata (2 posts)

  1. jahanzaib rao
    Member
    Posted 1 year ago #

    Displays non-editable attachment metadata in the publish metabox

    Signature:
    attachment_submitbox_metadata
    Return:
    (void)
    Source
    function attachment_submitbox_metadata() {
    $post = get_post();

    $filename = esc_html( basename( $post->guid ) );

    $media_dims = '';
    $meta = wp_get_attachment_metadata( $post->ID );
    if ( is_array( $meta ) && array_key_exists( 'width', $meta ) && array_key_exists( 'height', $meta ) )
    $media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']} × {$meta['height']}</span> ";
    $media_dims = apply_filters( 'media_meta', $media_dims, $post );

    $att_url = wp_get_attachment_url( $post->ID );
    ?>
    <div class="misc-pub-section">
    <label for="attachment_url"><?php _e( 'File URL:' ); ?></label>
    <input type="text" class="widefat urlfield" readonly="readonly" name="attachment_url" value="<?php echo esc_attr($att_url); ?>" />
    </div>
    <div class="misc-pub-section">
    <?php _e( 'File name:' ); ?> <?php echo $filename; ?>
    </div>
    16 more lines...

  2. jahanzaib rao
    Member
    Posted 1 year ago #

    it will help you:)

Topic Closed

This topic has been closed to new replies.

About this Topic