function to handle to show file size i.e.
paste this code in functions.php
/*
* @param string $fileSize Filepath
* @param int $digits Digits to display
* @return string|bool Size (KB, MB, GB, TB) or boolean
*/
function getFilesize($fileSize, $digits=2) {
$sizes = array("TB","GB","MB","KB","B");
$total = count($sizes);
while ($total-- && $fileSize > 1024) {
$fileSize /= 1024;
}
return round($fileSize, $digits)." ".$sizes[$total];
}
paste this code in single.php
if($kpmFile !== get_post_custom_values("kpm_UploadFile")) {
$head = array_change_key_case(get_headers("http://example.net/publications/Wellspring-of-Hope.pdf", TRUE));
echo $filesize = getFilesize($head['content-length']);
}
Related Posts:
- Where are custom field values stored in the database
- Using TinyMce with textareas in meta boxes on custom post types
- How to display all custom fields associated with a post?
- How can I fetch CSS from JSON WP REST API response
- ACF – get_field() using ‘option’ as post_id not working
- How to set a default meta value for custom field
- Populating meta box with select-list of existing posts, and assigning it to custom post types
- Create meta boxes that don’t show in custom fields
- How To Create a Metabox of HTML Content with Instructions For Editors When Editing a Post or Page?
- wp_editor in add_meta_boxes does not show gallery
- Calling Specific Pages with wp query Part II
- How do I assign this filter to a variable? (Appending php & markup to the_content)
- If value present, order posts by two consecutive custom fields
- Copying Custom Meta Values from existing post to a duplicate post
- Deleting a custom field field
- custom field to always to .get_the_title()?
- Displaying posts with only upcoming dates according their custom field date value
- How to filter a dd/mm/yyyy date from a custom field in a query
- How do I add custom_meta_box_id’s value?
- Get a post_id where meta_value equals something in a serialized meta_value field
- List posts with common custom field value
- Importing users to Buddypress with custom fields
- Including Database Generated Pages in Site Search [closed]
- Is it bad to use a lot of Custom Meta Fields?
- How to get customfield value by woocommerce product ID
- How do I get the url slug inside the dashboard for a custom post type?
- How to save media files under custom folder without changing wp-config.php or changing media settings
- How can I sort homepage by a meta value?
- Audio player shortcode not showing up when using variable
- get_posts that match a user-specified value on a page
- How to add image attachment to post from a single meta key (Woocommerce)
- Custom Fields – Taller editing area
- How to add Advenced Custom Fields In Single Post
- how to upload a image from frontend with wp_insert_post and also update_post_meta?
- Get updated meta value after post update or published (custom post type) using hook
- How to hide a custom field if there is not a value
- custom-meta-box checkboxes from loop won’t save
- Custom dropdown field added to media gallery; how to get it to save properly?
- Insert a custom field into a shortcode and use it in post(s)
- Uploading PDF using Media Uploader
- Correct syntax for retrieving custom field in CPT
- $TBA Getting Translated to $0 (Custom Fields)
- How Do I Display A Custom Field In The Sidebar Of All My Pages?
- Query_posts with custom field meta value
- Hide text if one custom field out of two is empty [closed]
- Echo the custom field value from the latest post from the ‘video’ post format?
- Custom Field – Do Not Show if Value is Empty?
- Move Title and the Content WYSIWYG editor position
- What’s the best way to implement custom widgets on a per post basis?
- Displaying Meta-Box Data Properly
- wp custom field date format compare
- frontend submit post jQuery clone row won’t save
- WordPress colorpicker save both hex and RGB
- Can’t get video meta from wp_read_video_metadata()
- Include one custom field in search results
- Custom search SQL Query to add custom field in result
- Search Results Page – Displaying Custom Meta Fields
- Can wp_insert_post_data filter be used to save custom field data?
- Meta query relation ‘OR’ not working as expected
- Interrogate a page within a loop to check template type or custom meta data (Pages vs Posts)
- using advanced custom field to control css hover color
- Custom Field data only shows after manual post update
- Custom field Search with Relavanssi
- How to exclude custom fields from search queries?
- Add Custom Fields After Page Title
- Footnotes in custom fields
- Image upload and path to custom field
- How to show content of custom fields in search results?
- simple fields plugin custom query
- Set class if a meta value is set within post archive
- Using Customizer API vs Custom Meta Box for custom content
- Filtering posts by ACF meta query
- Allow HTML in Custom Metabox area
- checking liked user in wordpress rest api
- How to display selected option from dropdown list in a metabox
- Custom meta boxes – add php code inside?
- How to use a custom field with add_rewrite_rule()?
- User custom meta delete by serialised key value
- Metabox value for post loop?
- How to add a default field Name to post Custom Fields
- Using ACF Custom Field value in a URL with do_shortcode() [closed]
- Custom Post Field -> Returning only the word “array”
- Register author, facebook connect, publish posts from front end
- Custom field and category query
- Empty the_content for all posts
- Extend WP_Customize_Control with Multiple Field Control
- Display different category template if custom field is checked
- How to use page metadata while using wp_list_pages()?
- Validating custom meta boxes with jQuery results in posts being saved as draft instead of published post
- Running a Gallery Shortcode in a Custom Fields Widget
- How can I create more “create attachment” custom field – any idea?
- Custom Metaboxes, multiple post selection
- How to sort Custom Fields by a value
- How to show custom field and parent post id in wordpress attachment page (image.php)
- Multiple image uploader under editor?
- Display agents (custom post type) alphabetically, except one who always shows last
- Custom Search, MySql Query Gone Wrong?
- Send checkout page custom field in order email
- Multiple triggers when publishing, saving or updating a post in WordPress
- If possible a field ID transfom in a Custom Field?