Outbound Feeds Image Resizer v2 Upgrade and Configuration Guide
Configuration updates for Outbound Feed blocks
High-level checklist (see below for full details)
- Update your Engine environment files
- Update
resizerURLs
in yourblocks.json
file - Update your
package.json
dependencies
1. Update your Engine environment files
In OBF 2.0.0, the feed blocks will automatically utilize Resizer v2 when you make the following environment variable changes in your Outbound Feeds feature pack:
RESIZER_TOKEN_VERSION
: Set variable to match the currently enabled SSM version for your organization’s secret as obtained from the “Get HMAC Keys” section under the Organization tab in the Arc XP Delivery API documentation. This ensures secure and proper functioning of the outbound feeds with Resizer v2.SIGNING_SERVICE_DEFAULT_APP
: Set toresizer
to indicate the default application for signing services.BLOCK_DIST_TAG
: Set sandbox tobeta
, and production set tostable
.resizerKey
: Remove this key, it’s no longer needed.- For local development you’ll want to add a
environment/localhost.js
with the variables:
{ "BLOCK_DIST_TAG": "stable", "RESIZER_TOKEN_VERSION": 1, "SIGNING_SERVICE_DEFAULT_APP": "resizer"}
After making the updates to your environment.json
file(s), re-deploy your bundle in order for OBF 2.0.0 blocks to install with the latest published packages under the BLOCK_DIST_TAG
.
2. Update resizerURLs in your blocks.json file
In OBF 2.0.1, a resizerURLs
object for each site’s siteProperties
should be added in the blocks.json
of your Outbound Feeds bundle to specify resizer v2 URLs for each OBF environment.
- Add a
resizerURLs
object within each site’ssiteProperties
to yourblocks.json
. Within that object, add keys relating to your environments, such asorg-outboundfeeds-sandbox
andorg-outboundfeeds
. The values will be the resizer v2 URL for each environment. - For local development, also add a
localhost
key and the resizer v2 URL for the environment you’ve set your local to fetch content from (below example is using sandbox for localhost). - Replace the
org
andsite
values with what is specific to your configuration per site, and your production resizerURL can be the domain you use rather than the raw Arc CDN. - Remove the existing
resizerURL
as theresizerURLs
object will take priority over it....,"{siteId}": {"siteProperties": {...,"resizerURLs": {"{org}-outboundfeeds-sandbox": "https://{org}-{siteId}-sandbox.web.arc-cdn.net/resizer/v2","{org}-outboundfeeds": "https://{org}-{siteId}-prod.web.arc-cdn.net/resizer/v2","localhost": "https://{org}-{siteId}-sandbox.web.arc-cdn.net/resizer/v2"}}},...,
3. Update package.json dependencies
OBF related @wpmedia/feeds-*
dependencies defined in your package.json should also have the expected version or npm dist tag.
- Review your package.json for
@wpmedia/feeds-{packageName}
dependency versions. - Update these to
beta
for evaluating the sandbox release, and change tostable
for the production release.
Configuration updates for Custom Feed blocks
In addition to the changes above, you will need to use the new signing service pattern and update OBF feed dependency versions in your package.json
, to use Resizer v2 in your custom outbound feed blocks.
Example of feeds-source-content-api.js
Resizer v2 changes
Let’s step through the updates made to feeds-source-content-api.js
Changes at the import
-
Added
axios
(make sure that is in your package.json dependencies). -
Including three additional environment variables from
fusion:environment
ARC_ACCESS_TOKEN,RESIZER_TOKEN_VERSION,resizerKey, -
@wpmedia/feeds-resizer
is a new import, destructuring outsignImagesInANSObject
andresizerFetch
Changes at the function definition
- Changing from a resolve to a
fetch
because we need to use axios and chain a signing service call. cachedCall
is also now in the signature of the function. See Partial caching on PageBuilder Engine for more details.(key, { cachedCall })
Changes at the function return
- Shifting from
resolve
tofetch
means a change to how we’re making the request. The change now uses axios chains promise that usessignImagesInANSObject
. - The previous
resolve
also had a transform which we’ve now moved into another promise.then
Sample code of the axios fetch pattern:
const ret = axios({ url: `${requestUri}?body=${encodedBody}&${genParams(paramList)}`, headers: { 'content-type': 'application/json', Authorization: `Bearer ${ARC_ACCESS_TOKEN}`, }, method: 'GET', }) .then((result) => { if (resizerKey) { return result } return signImagesInANSObject( cachedCall, resizerFetch, RESIZER_TOKEN_VERSION, )(result) }) .then(({data, ...rest}) => ({ ...rest, data: transform(data, key), })) .then(({ data }) => data) .catch((error) => console.log('== error ==', error))
return ret}
Changes at the export
- resolve is swapped to fetch
- transform is removed as it shifted into the axios promise chain
Example of updating a feed that handles resizing
The utility to handle resizing in OBF has been buildResizerURL
from the @wpmedia/feeds-resizer
package.
To begin using Resizer v2 you just need to add the ANS image object as the last argument in the buildResizerURL
function.
If you come across a usage of buildResizerURL
in a custom feed where there are no arguments for resizerWidth
and resizerHeight
then it likely means this is an external image url. The raw image url passed into the function will be returned back with no resizing as there is no width or height.
An example of this can be seen with the optional channel logos that are not ANS objects, and are external urls defined as a custom field in PageBuilder Editor on the block: