Skip to content

Commit

Permalink
Merge pull request #2824 from timber/fix-attachment-size-doc-block
Browse files Browse the repository at this point in the history
fix: Attachment size doc block
  • Loading branch information
nlemoine committed Oct 20, 2023
2 parents 88d0006 + 0bd5791 commit 58d6719
Showing 1 changed file with 5 additions and 6 deletions.
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

0 comments on commit 58d6719

Please sign in to comment.