Pipit Cloudinary v1.1
Pipit Cloudinary is a Perch template filter that enables you to easily fetch your images to Cloudinary on the fly. Cloudinary also gives you the option to manipulate your images with dynamic URLs. The new version brings a few changes.
Site URL in config
By default, the filter now uses your site URL as you define it in in your config file perch/config/config.php
:
define('SITE_URL', 'https://example.com');
If you don’t define SITE_URL
, the URL from Perch Settings will be used as a fallback.
The main reason for this change is to make it more practical to set up the filter to work correctly across different environments. With v1.0, you had to set a different URL in the Settings via the control panel. So whenever you update your database from one environment, you had to update the site URL via the control panel.
Now you can configure this once:
switch(PERCH_PRODUCTION_MODE) {
case PERCH_STAGING:
define('SITE_URL', 'http://staging.example.com');
break;
default:
define('SITE_URL', 'https://example.com');
}
This will also protect you from an admin changing the URL via the control panel and breaking the image URLs.
Enable on dev/staging
v1.0 disabled the filter on development environment and enabled it on staging and production environment by default.
To give you more control over this behaviour, you now have to explicitly enable the filter for development and staging environments (i.e. it is disabled by default):
switch(PERCH_PRODUCTION_MODE) {
case PERCH_DEVELOPMENT:
define('SITE_URL', 'https://example.loc');
break;
case PERCH_STAGING:
define('PIPIT_CLOUDINARY_DEV', true);
define('SITE_URL', 'http://staging.example.com');
break;
default:
define('SITE_URL', 'https://example.com');
}
External vs internal images
The filter now automatically detects whether the image is an internal or external image and generate the Cloudinary URL accordingly. As a result, the external
attribute is deprecated.