AnsweredAssumed Answered

execute a script only for a special filename

Question asked by stegbth on Dec 23, 2015
Latest reply on Jan 20, 2016 by niketapatel

i am trying to mogrify uploaded pictures to a fixed size.
so i found here an appropriate Javascript here
I created a rule, which execute the script when a jpeg get uploaded, which
is not optimal, cause this runs in an endless loop.

Now i tried to check the documentname in the script if it contains or
starts with resized_.. but no solution as described here - -

Could some hint me to the correct syntax for the if clause?

The currect Script looks like this:

var strOrigName =;
var jstrOrigName = new java.lang.String(;

if (!jstrOrigName.contains("resized_")) {
var tmpName = "resized_" +; = tmpName;
var rImage=document.transformImage("image/jpeg","-normalize -resize
1024x768", document.parent);
if (rImage){ = strOrigName;;

This are some tests i made as described here

var jstrOrigName = new java.lang.String(;
if (!jstrOrigName.contains("resized_")) {

Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "java" is not defined

var jSstrOrigName = new String(;
if (!jSstrOrigName.contains("resized_")){

no function resize

if (strOrigName.indexOf("resized_") != -1){

no error, no resize

best regards