get_media_item example

$attachments[ $attachment->ID ] = $attachment;
            }
        }
    }

    $output = '';
    foreach ( (array) $attachments as $id => $attachment ) {
        if ( 'trash' === $attachment->post_status ) {
            continue;
        }

        $item = get_media_item( $id, array( 'errors' => isset( $errors[ $id ] ) ? $errors[ $id ] : null ) );

        if ( $item ) {
            $output .= "\n<div id='media-item-$id' class='media-item child-of-$attachment->post_parent preloaded'><div class='progress hidden'><div class='bar'></div></div><div id='media-upload-error-$id' class='hidden'></div><div class='filename hidden'></div>$item\n</div>";
        }
    }

    return $output;
}

/** * Retrieves HTML form for modifying the image attachment. * * @since 2.5.0 * * @global string $redir_tab * * @param int $attachment_id Attachment ID for modification. * @param string|array $args Optional. Override defaults. * @return string HTML form for attachment. */
echo '<a class="edit-attachment" href="' . esc_url( get_edit_post_link( $id ) ) . '">' . _x( 'Edit', 'media item' ) . '</a>';
                    } else {
                        echo '<span class="edit-attachment">' . _x( 'Success', 'media item' ) . '</span>';
                    }
                    ?> </div> </div> <?php             break;
        case 2:
            add_filter( 'attachment_fields_to_edit', 'media_single_attachment_fields_to_edit', 10, 2 );
            echo get_media_item(
                $id,
                array(
                    'send'   => false,
                    'delete' => true,
                )
            );
            break;
        default:
            add_filter( 'attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2 );
            echo get_media_item( $id );
            break;
    }
Home | Imprint | This part of the site doesn't use cookies.