Working with assets

Working with images

Images can be uploaded to the action, they can be referenced from outside url or they can be part of the actions files.

When they are part of the action’s file, they can either reside on the main level or be put into the themes directory. In general, images are referred only by their name within the PHP code. Appzio system takes care of copying assets to right places & resizing them.

Screen Shot 2017-01-20 at 08.59.34

Screen Shot 2017-01-20 at 08.59.43

The most basic usage for getting an image:

$this->getImage('search-icon-for-field.png');

Getting an image with some parameters:

$imageparams['crop'] = 'round';
$imageparams['width'] = '40';
$imageparams['margin'] = '0 10 0 0';
$imageparams['priority'] = 9;
$imageparams['imgwidth'] = 250;
$imageparams['imgheight'] = 250;
$this->getImage($this->getSavedVariable('profilepic'),$imageparams);

About asset priorities
1 = download these assets before client starts
2 = download as soon as possible
3 … 7 = download whenever action is part of the list branches response
7 = download only when needed to show, cache on client only temporarily
9 = download only when needed to show, try to delete after session

Copying images to be used for backgrounds or within styles file

$this->copyAssetWithoutProcessing('my-unique-background-name.png');
 $this->data->scroll[] = $this->getColumn($col,array(
 'background-image' => 'my-unique-background-name.png', 'background-size' => 'cover',
 'vertical-align' => 'middle','text-align' => 'center',
 'width' => $this->screen_width));