Upload::file_list()

Description #

Show the list of previously attached media.

Changelog #

VersionDescription
4.1.8Introduced.

Source #

File: lib/form/class-upload.php

	public function file_list() {
		$medias = get_posts(
			array(
				'post_type'   => 'attachment',
				'title'       => '_ap_temp_media',
				'post_author' => get_current_user_id(),
			)
		);

		// Show temporary images uploaded.
		$this->add_html( '<div class="ap-upload-list">' );

		if ( $medias ) {
			foreach ( $medias as $media ) {
				$this->add_html( '<div><span class="ext">' . pathinfo( $media->guid, PATHINFO_EXTENSION ) . '</span>' . basename( $media->guid ) . '<span class="size">' . size_format( filesize( get_attached_file( $media->ID ) ), 2 ) . '</span></div>' );
			}
		}

		$this->add_html( '</div>' );
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment