Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Attachment size doc block #2824

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,26 +209,25 @@ public function caption(): string
}

/**
* Gets filesize in a human readable format.
* Gets the raw filesize in bytes.
*
* This can be useful if you want to display the human readable filesize for a file. It’s
* easier to read «16 KB» than «16555 bytes» or «1 MB» than «1048576 bytes».
* Use the `size_format` filter to format the raw size into a human readable size («1 MB» intead of «1048576»)
*
* @api
* @since 2.0.0
* @example
* @see https://developer.wordpress.org/reference/functions/size_format/
*
* Use filesize information in a link that downloads a file:
*
* ```twig
* <a class="download" href="{{ attachment.src }}" download="{{ attachment.title }}">
* <span class="download-title">{{ attachment.title }}</span>
* <span class="download-info">(Download, {{ attachment.size }})</span>
* <span class="download-info">(Download, {{ attachment.size|size_format }})</span>
* </a>
* ```
*
* @return int|null The filesize string in a human-readable format or null if the
* filesize can’t be read.
* @return int|null The raw filesize or null if it could not be read.
*/
public function size(): ?int
{
Expand Down