Pageimage class
Represents an image item attached to a page, typically via an Image Fieldtype.
Pageimage objects are usually contained by a Pageimages object, which is a type of Pagefiles and WireArray. In addition to the methods and properties below, you'll also want to look at Pagefile which this class inherits
several important methods and properties from.
// Example of outputting a thumbnail gallery of Pageimage objects
foreach($page->images as $image) {
// $image and $thumb are both Pageimage objects
$thumb = $image->size(200, 200);
echo "<a href='$image->url'>";
echo "<img src='$thumb->url' alt='$image->description' />";
echo "</a>";
}Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the Pageimage class also inherits all the methods and properties of: Pagefile, WireData and Wire.
Common
Resize and crop
Variations
A variation refers to an image that is based upon another (like a resized or cropped version for example).
Other
| Name | Return | Summary | |
|---|---|---|---|
| Pageimage::HTTPURL | string | Same as the cache-busting uppercase “URL” property, but includes scheme and hostname. | |
| Pageimage::URL | string | Same as $url property but with browser cache busting query string appended. | |
| Pageimage::field | Field | The Field object that this file is part of. | |
Pageimage::focus() Pageimage::focus() Pageimage::focus($top = null, $left = null, $zoom = null) | array bool Pageimage | Get or set focus area for crops to use Can also be used as property: Pageimage::focus | |
| Pageimage::page | Page | The Page object that this file is part of. | |
| Pageimage::pagefiles | Pagefiles | The Pagefiles WireArray that contains this file. | |
Pageimage::suffix() Pageimage::suffix() Pageimage::suffix(string $s = '') | array bool | Returns array of suffixes for this file, or true/false if this file has the given suffix. Can also be used as property: Pageimage::suffix |
Manipulation
| Name | Return | Summary | |
|---|---|---|---|
Pageimage::rename() Pageimage::rename(string $basename) Pageimage::rename(string $basename) | string bool | Rename this file |
Properties
| Name | Return | Summary | |
|---|---|---|---|
| Pageimage::alt | string | Convenient alias for the 'description' property, unless overridden 3.0.125. | |
| Pageimage::basename | string | Returns the filename without the path. | |
| Pageimage::debugInfo | PageimageDebugInfo | ||
| Pageimage::description | string | Value of the file’s description field (string), if enabled. Note you can also set this property directly. | |
| Pageimage::ext | string | File’s extension (i.e. last 3 or so characters) | |
| Pageimage::filesize | int | File size (number of bytes). | |
| Pageimage::filesizeStr | string | File size as a formatted string, i.e. “123 Kb”. | |
| Pageimage::focusStr | string | Readable string containing focus information. | |
| Pageimage::hasFocus | bool | Does this image have custom focus settings? (i.e. $focus['default'] == true) | |
| Pageimage::hash | string | Get a unique hash (for the page) representing this Pagefile. | |
| Pageimage::httpUrl | string | URL to the file on the server including scheme and hostname. | |
| Pageimage::name | string | Returns the filename without the path, same as the "basename" property. | |
| Pageimage::src | string | Convenient alias for the 'url' property, unless overridden 3.0.125. | |
| Pageimage::suffixStr | string | String of file suffix(es) separated by comma. |
Tags
| Name | Return | Summary | |
|---|---|---|---|
| Pageimage::tags | string | Value of the file’s tags field (string), if enabled. | |
| Pageimage::tagsArray | array | Get file tags as an array. |
Date time
| Name | Return | Summary | |
|---|---|---|---|
| Pageimage::created | int | Unix timestamp of when file was created. | |
| Pageimage::createdStr | string | Readable date/time string of when Pagefile was created | |
| Pageimage::modified | int | Unix timestamp of when Pagefile (file, description or tags) was last modified. | |
| Pageimage::modifiedStr | string | Readable date/time string of when Pagefile was last modified. | |
| Pageimage::mtime | int | Unix timestamp of when file (only) was last modified. | |
| Pageimage::mtimeStr | string | Readable date/time string when file (only) was last modified. |
Additional methods and properties
In addition to the methods and properties above, Pageimage also inherits the methods and properties of these classes:
API reference based on ProcessWire core version 3.0.252