Title: [Plugin: WP Publication Archive] display filesize
Last modified: August 20, 2016

---

# [Plugin: WP Publication Archive] display filesize

 *  [LLvS](https://wordpress.org/support/users/llvs/)
 * (@llvs)
 * [14 years ago](https://wordpress.org/support/topic/plugin-wp-publication-archive-display-filesize/)
 * I want to display my downloads other than it’s in the original code, so I missed
   the filesize, so I added a new function to the plugin, maybe it will help you.(
   You have to make a copy of the plugin to not overwrite it on updates.) This will
   only work correct if your are only using internal documents.
 * open class.publication-markup.php and add
 *     ```
       public function get_the_reallink() {
       		$uri = apply_filters( 'wpa-uri', $this->uri, $this->ID );
       		$uri = str_replace('|', '://', $uri);
       		return $uri;
       	}
   
       	public function get_the_size() {
       		clearstatcaches;
       		$uri = $this->get_the_reallink();
       		$uri = str_replace(get_option('home'), $_SERVER['DOCUMENT_ROOT'], $uri, $count);
       		if ($count = 0) {
       			$uri = str_replace(get_option('home'), $_SERVER['DOCUMENT_ROOT'], $uri);
       		}
       		return $this->format_bytes(filesize($uri));
       	}
   
       	private function format_bytes($a_bytes) {
       		if ($a_bytes < 1024) {
               	return number_format ($a_bytes , 2, ',', '.') .' B';
           	} elseif ($a_bytes < 1048576) {
               	return number_format (round($a_bytes / 1024, 2) , 2, ',', '.') .' KiB';
           	} elseif ($a_bytes < 1073741824) {
               	return number_format (round($a_bytes / 1048576, 2) , 2, ',', '.') . ' MiB';
           	} else {
               	return number_format (round($a_bytes / 1073741824, 2) , 2, ',', '.') . ' GiB';
           	}
       	}
       ```
   
 * open class.wp-publication-archive.php and edit the function shortcode_handler
   to display the filesize

Viewing 1 replies (of 1 total)

 *  Plugin Author [Eric Mann](https://wordpress.org/support/users/ericmann/)
 * (@ericmann)
 * [14 years ago](https://wordpress.org/support/topic/plugin-wp-publication-archive-display-filesize/#post-2691174)
 * Please submit your changes as a patch, or fork the plugin on GitHub ([https://github.com/ericmann/WP-Publication-Archive](https://github.com/ericmann/WP-Publication-Archive))
   and submit a pull request so I can include this functionality.

Viewing 1 replies (of 1 total)

The topic ‘[Plugin: WP Publication Archive] display filesize’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-publication-archive_e8e9e7.svg)
 * [WP Publication Archive](https://wordpress.org/plugins/wp-publication-archive/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-publication-archive/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-publication-archive/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-publication-archive/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-publication-archive/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-publication-archive/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Eric Mann](https://wordpress.org/support/users/ericmann/)
 * Last activity: [14 years ago](https://wordpress.org/support/topic/plugin-wp-publication-archive-display-filesize/#post-2691174)
 * Status: not a support question