Pageimage::width() method

Return the width of this image OR return an image sized with a given width (and proportional height).

  • If given a width, it'll return a new Pageimage object sized to that width.
  • If not given a width, it'll return the current width of this Pageimage.

Example

// Get width of image
$px = $image->width();

// Create a new variation at 200px width
$thumb = $image->width(200); 

Usage

// basic usage
$int = $pageimage->width();

// usage with all arguments
$int = $pageimage->width(int $n = 0, $options = []);

Arguments

NameType(s)Description
n (optional)int

Optional width if you are creating a new size.

options (optional)array, string, int, bool

See Pageimage::size() $options argument for details.

Return value

int Pageimage

Returns width (in px) when given no arguments, or Pageimage when given a width argument.


Pageimage methods and properties

API reference based on ProcessWire core version 3.0.148

Twitter updates

  • Weekly update for Jan 10, 2020—front-end file uploads in LoginRegisterPro with InputfieldFrontendFile module: More
    10 January 2020
  • If you haven't seen it yet, be sure to check out this great infographic by @teppokoivula in ProcessWire Weekly #294— How ProcessWire professionals work—the results of our recent weekly polls summarised: weekly.pw/issue/294/#how…
    3 January 2020
  • Today we have a new master version released, 3.0.148! There are 25 new versions worth of upgrades, fixes and optimizations in this new master version, relative to the previous. In this post we take a closer look at what’s new, how to upgrade, & more— More
    3 January 2020

Latest news

  • ProcessWire Weekly #298
    In the 298th issue of ProcessWire Weekly we're going to take a quick look at the latest core updates, introduce the PWGeeks project, and highlight some recently released ProcessWire content. Read on!
    Weekly.pw / 25 January 2020
  • ProcessWire 3.0.148 new master
    Today we have a new master version released, version 3.0.148! The last master version was 3.0.123, so there are 25 new versions worth of upgrades, fixes and optimizations in this new master version, relative to the previous. In this post we’ll take a closer look at what’s new, how to upgrade, and more.
    Blog / 3 January 2020
  • Subscribe to weekly ProcessWire news

“To Drupal, or to ProcessWire? The million dollar choice. We decided to make an early switch to PW. And in retrospect, ProcessWire was probably the best decision we made. Thanks are due to ProcessWire and the amazing system and set of modules that are in place.” —Unni Krishnan, Founder of PigtailPundits