Skip to content

Commit

Permalink
Addd a new Medium:exists() method
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Jan 31, 2018
1 parent 19ae66d commit 08be06c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Added new `Collection::toExtendedArray()` method that's particularly useful for Json output of data
* Added new `|yaml_encode` and `|yaml_decode` Twig filter to convert to and from YAML
* Added new `read_file()` Twig function to allow you to load and display a file in Twig (Supports streams and regular paths)
* Added a new `Medium::exists()` method to check for file existence
1. [](#improved)
* Better `Page.collection()` filtering support including ability to have non-published pages in collections

Expand Down
14 changes: 14 additions & 0 deletions system/src/Grav/Common/Page/Medium/Medium.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,20 @@ public function meta()
return new Data($this->items);
}

/**
* Check if this medium exists or not
*
* @return bool
*/
public function exists()
{
$path = $this->get('filepath');
if (file_exists($path)) {
return true;
}
return false;
}

/**
* Returns an array containing just the metadata
*
Expand Down

0 comments on commit 08be06c

Please sign in to comment.