Setup Image Core

Image Core is one of the most complicated of the FW Addons to setup, and all of the generic and specific steps must be followed specifically in order to set it up correctly.

Generic Setup

Of course, before any of the specific setup for the addon can be completed, you must do the generic setup for all addons to install it to the app. If you forgot how to do this, see Setup section of Using Addons in the main docs.

Specific Image Core Setup

Because of the complexity of Image Core setup, there are many different files that need to be updated. In general there are two aspects that are needed to be added to make sure Image Core functions correctly: an image table on the database (to store the data), and the image template asset (to render the data). Getting each of these steps working takes multiple files.

Add Image Table

Since Image Core after version 3.3 uses the database to save the images, rather than a server folder, making an image table for the app is very important. You need to make a new migration, (if you don't know how to do this, see Migration Core docs), making a table with the name appName_image, and columns in the following way:

//tally should be replaced with the app code for whichever app you are developing
public function change() {
    $this->table('tally_image', ['id' => 'imgAID'])
         ->addColumn('img_image', 'text', ['limit'=>4294967295])
         ->addColumn('img_name', 'string', ['null'=>true, 'limit'=>64])
         ->addColumn('img_type', 'string', ['limit'=>64])
         ->addColumn('img_time', 'timestamp', ['default'=>'CURRENT_TIMESTAMP',
                'update'=>'CURRENT_TIMESTAMP'])
         ->addColumn('img_category', 'string', ['null'=>true])
         ->create();
}

Note: It is vital that you copy this migration exactly, if the column names are not correct, the image core addon will not work properly.

Additionally, in order to allow the table to be properly called, you also need to add the image-core settings to the app-dir/apps/my-app/server/config/app.php file. You should set the imageTable attribute to the name of your table. For example, add the following line to app.php:

return [
    // other settings already existing
    'image-core.imageTable' => 'tally_image'
];

Adding the Image Template Asset

There are three steps that need to be completed to successfully enable the images.php template to render the images correctly.

First, because there is a blueprint file in Image Core, you need to copy the files in the blueprint files to their exact location in your app (as the addon documentation suggests). In this case, you need to take the file blueprint/client/public/assets/images.php and save it as client/public/assets/images.php (as the blueprint folder would suggest).

Second, you need to make sure that the imagePath value is set in the fw.json file correctly, so the app will know where to find the image in the config variable. Add imagePath to fw.json in the following way (at the end of the fw.json file):

{
    "imagePath": "assets/images.php"
}

Finally, you need to make sure that the asset can actually be delivered using our asset delivery system. Usually, in apps, which don't use Image Core, it is expected that the only php file that will be delivered as an asset is our api/v1.0.php file, so it very specifically filters for that sort of title using regex. We need it to allow for all php files (since images.php is an asset), so change the regex on line 43 of client/lib/asset-delivery/index.js to allow any php files. In the end, you should change the line from what it was originally:

if (relativePath.match(/api\/v[0-9\.]+\.php$/) && apiRoot && !process.env.RELEASE_BUILD) {
//code
}

to the following:

if (relativePath.match(/\.php$/) && apiRoot && !process.env.RELEASE_BUILD) {
 // code
}