jchristopher / attachments

[WordPress Plugin] Attachments allows you to simply append any number of items from your WordPress Media Library to Posts, Pages, and Custom Post Types
wordpress.org/extend/plugins/attachments/
GNU General Public License v2.0
241 stars 78 forks source link

Filesize function only properly works if using native WordPress storage #180

Open ddbradshaw opened 6 years ago

ddbradshaw commented 6 years ago

I have a client that doesn't use the native WordPress storage for files, instead they use Windows Azure for file storage. This being the case, the file_exists method always returns false. Here's a workaround that worked for me in the class.attachments.php

$head = array_change_key_case(get_headers($file_path, TRUE));
$filesize = $head['content-length'];
$formatted = size_format( $filesize );