Skip to content

Instantly share code, notes, and snippets.

@pepebe
Forked from jenswittmann/collections.imageplus.js
Created September 16, 2018 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pepebe/01ff9813794e8b05550235473ce4de2e to your computer and use it in GitHub Desktop.
Save pepebe/01ff9813794e8b05550235473ce4de2e to your computer and use it in GitHub Desktop.
Custom MODX Collections renderer for Image+ with cropping
collections.renderer.imageplus = function(value, metaData, record, rowIndex, colIndex, store) {
if (value != '' && value != null) {
var data = Ext.decode(value);
var url = MODx.config.connectors_url + 'system/phpthumb.php?imageplus=1';
var params = {};
params.src = 'upload/'+MODx.config['collections.renderer_image_path'] + data.sourceImg.src;
params.w = 100;
if (data.sourceImg.src.indexOf('.png') !== -1) {
params.f = 'png';
}
params.sx = data.crop.x;
params.sy = data.crop.y;
params.sw = data.crop.width;
params.sh = data.crop.height;
params.aoe = 1;
for (var i in params) {
url += '&' + i + '=' + params[i];
}
return '<img alt="" src="' + url + '" width="' + (params.w || 80) + '">';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment