How to shorten your $html->image() statements

Published on and tagged with cakephp  helper  tip

To include an image in a page, you probably use a code snippet similar to the one shown below:

$html->image('logo.png', array('width' => 500, 'height' => 300));

If you don’t want to type that much there is a little trick: use a string as second parameter. With that trick the previous example can be shortened to:

$html->image('logo.png', 'width="500" height="300"');

6 comments baked

Bake a comment




(for code please use <code>...</code> [no escaping necessary])

© daniel hofstetter. Licensed under a Creative Commons License