function run(doc, params) { var blobXPath = params.blobXPath; if (!blobXPath) { Console.warn(params); Console.warn('No blobXPath parameter'); return doc['file:content']; } // change the blob returned by the adapter only if we request the default blob if (blobXPath === 'file:content') { // change the blob returned by the adapter only if we request blob of a Picture document // and we don't request a pdf or psd var mimeType = doc['file:content/mime-type']; if (doc.hasFacet('Picture') && mimeType !== 'image/vnd.adobe.photoshop' && mimeType !== "application/pdf") { Console.warn('Document + blob are candidate for rendition'); var pictureViews = doc['picture:views']; for (var index = 0; index < pictureViews.length; index++) { var view = pictureViews[index]; if (view.title === 'OriginalJpeg' && view.content.filename !== 'empty_picture.png') { Console.warn('Found a picture view'); return view.content; } } Console.warn('Blob is not ready'); } } Console.warn('Normal return'); return doc[blobXPath]; }