Image clear option does not remove autogenerated thumbnail

We are using “PSOThumbnailGenerator” for creating auto thumbnails. Once we create a new content item, upload the main image and save it , we are able to preview the content item which displays autogenerated thumbnail and main uploaded image. But the issue is that if we clear the main image from the content item, save it and preview the same, it still displays the previously generated auto thumbnail image on the page. On clearing the main image from the content item, it does not clear the auto generated thumbnail. After publishing, thumbnail gets published and displayed on page even after clearing the main image.

Please send us the way to clear auto generated thumbnail while clearing the main image from the content item.

The Thumbnail generator works as an Input Transform on the image field. Basically when the item is saved it takes the contents of the image field and tries to generate a thumbnail which it stores in your thumbnail field.

Looking at the code I don’t see that it has a condition to handle the image being removed, so it makes sense that the thumbnail is still “on” the item. That would be a good enhancement to the extension to log here.

I don’t have time to test this right now, but one thing you could try in the mean time, is to add an input transform rule like “Set Field” on the thumbnail fields. In the JEXL for that rule test if the image field / filename is empty, if it is, then set the thumbnail fields to “”.

-n

Thanks Nate for your reply.

We tried to resolve the issue with steps suggested by you. We tried to write the JEXL expression for Input Transform (set field) but could not succeed as we got error while saving the content item (Not able to evaluate the JEXL Expression). We followed the below steps and got success:

  1. Open erauDepartment content type.
  2. Select img200 field and click on All Properties button(bottom right side), Field Properties dialog box appears.
  3. Click on Transforms button(bottom side 4th button), new Field Transform dialog box appears.
  4. Select Transform Type as Set Field and write JEXL expression as “” and press Apply button.
  5. Press Ok button of Field Transform dialog box and Ok button of Field Properties dialog box.
  6. Repeat steps 2 to 5 for img200_ext, img200_filename, img200_height, img200_width, img200_size, img200_type fields also.

Please suggest if this approach is correct or send us the JEXL expression so that we can use it in input transform.

Could you paste the JEXL expression that you were using for one of the fields here? It may just be a syntax error.

Thanks!

-n

[QUOTE=vgupta;20774]Thanks Nate for your reply.

We tried to resolve the issue with steps suggested by you. We tried to write the JEXL expression for Input Transform (set field) but could not succeed as we got error while saving the content item (Not able to evaluate the JEXL Expression). We followed the below steps and got success:

  1. Open erauDepartment content type.
  2. Select img200 field and click on All Properties button(bottom right side), Field Properties dialog box appears.
  3. Click on Transforms button(bottom side 4th button), new Field Transform dialog box appears.
  4. Select Transform Type as Set Field and write JEXL expression as “” and press Apply button.
  5. Press Ok button of Field Transform dialog box and Ok button of Field Properties dialog box.
  6. Repeat steps 2 to 5 for img200_ext, img200_filename, img200_height, img200_width, img200_size, img200_type fields also.

Please suggest if this approach is correct or send us the JEXL expression so that we can use it in input transform.[/QUOTE]

For input field transform, below JEXL expression is used for ‘img200’ field (‘img200’ field value is evaluated through ‘uploadfilephoto’ field via PSO thumbnail generator)

Transform Type : Set Field
JEXL expression : $rx.cond.choose($sys.item.getProperty(‘rx:uploadfilephoto_filename’).String.trim()== “”, “”, $sys.item.getProperty(“rx:img200”))

Hi vgupta,

You’re testing for String value equality, so use .equals() instead of ==, e.g:

$rx.cond.choose($sys.item.getProperty(‘rx:keywords’).String.trim().equals(’’), ‘no keywords’, ‘has keywords’)

Let us know if that works.

Best regards,
Chris Leger

[QUOTE=vgupta;20777]For input field transform, below JEXL expression is used for ‘img200’ field (‘img200’ field value is evaluated through ‘uploadfilephoto’ field via PSO thumbnail generator)

Transform Type : Set Field
JEXL expression : $rx.cond.choose($sys.item.getProperty(‘rx:uploadfilephoto_filename’).String.trim()== “”, “”, $sys.item.getProperty(“rx:img200”))[/QUOTE]

Hi Chris,

Thanks for posting the reply. We tried the solution suggested by you for Input transform on img200_filename field. But got the below error message while saving the content item:
An error occurred running a transformation on the field “img200_filename”: Problem evaluating expression: $rx.cond.choose($sys.item.getProperty(‘rx:uploadfilephoto_filename’).String.trim().equals(’’), ‘’, $sys.item.getProperty(‘rx:img200_filename’).String)

Any further help on this will be appreciated.

It appears that this approach is a dead-end. Field transforms can only access field data for the field at hand, and not other fields.

You might try altering the content lists used to publish the thumbnails - only publish when the size of the original image is greater than zero, for example.

You are right on Set Field Chris.

I did a little more looking, the Clear check box on an image field basically adds a Request parameter with the “image field name_clear” set to yes. This means that you can use the PSOCopyParameter input transform to get the functionality you want.

In Properties of the Content Type, in the Input Transforms list, add an entry for PSOCopyParameter after the PSOThumbnailGenerator transform.

Set the source parameter to be the name of your image field followed by _clear. So img1_clear for example.
Set the destination parameter to be the name of your thumbnail image field followed by _clear. So img200_clear for example.

Save the content type and try clearing the main image, this should clear both the thumbnail whenever the main image is cleared.

-n

[QUOTE=chris_leger;20780]It appears that this approach is a dead-end. Field transforms can only access field data for the field at hand, and not other fields.

You might try altering the content lists used to publish the thumbnails - only publish when the size of the original image is greater than zero, for example.[/QUOTE]

Hi Nate & Chris,

Thanks for posting the reply. We followed the steps suggested by you with little bit of deviation as we used sys_CopyParameter instead of pso_CopyParameter after psoThumbnailGenerator in the pre-processing tab of Content Type. pso_CopyParameter in pre-processing tab was throwing below exception while editing content item:

<Error id=“0”>An error occurred processing the query submitted by session id 3929e198832989f9d1fa86d34800dace757da796.</Error><Error id=“1”>java.lang.NumberFormatException: For input string: “”</Error><Error id=“2”>edit handler</Error>

Please find below entries for pre-processing tab of content type
sys_imageInfoExtractor()
PSOThumbnailGenerator(uploadfilephoto,img200,200-,720,200,)
sys_CopyParameter(uploadfilephoto_clear,img200_clear)

After following the above mentioned approach, if we remove the main image from the content item, save and preview it (with the respective velocity page template) we did not get autogenerated thumbnail in preview but when we preview the same content item with binary template “BnImg200” (for autogenerated thumbnail), we get autogenerated thumbnail in the preview.

Ideally after following the above mentioned approach, it should not display the autogenerated thumbnail in binary template preview also.

As per the above followed approach we assumed that the autogenerated thumbnail is getting removed from img200 field of content type but it seems the autogenerated thumbnail is also getting stored in some system field which the binary template is utilizing. Please find below the bindings for our binary template i.e. “BnImg200”:

$sys.binary : $sys.item.getProperty(“rx:img200”)
$sys.mimetype : $sys.item.getProperty(“rx:img200_type”)

Please suggest some centralized approach to remove the thumbnails so that it will not get displayed in both binary as well as velocity template preview.

Thanks.

I fixed this on the development branch of the toolkit. You can get that in the latest nightly snapshot. http://cdn.percussion.com/downloads/open/psotoolkit/PSOToolkit7.x-SNAPSHOT.zip The error you were getting with PSOCopyParameter is because the fieldSize parameter was not specified.

-n

[QUOTE=vgupta;20782]Hi Nate & Chris,

Thanks for posting the reply. We followed the steps suggested by you with little bit of deviation as we used sys_CopyParameter instead of pso_CopyParameter after psoThumbnailGenerator in the pre-processing tab of Content Type. pso_CopyParameter in pre-processing tab was throwing below exception while editing content item:

<Error id=“0”>An error occurred processing the query submitted by session id 3929e198832989f9d1fa86d34800dace757da796.</Error><Error id=“1”>java.lang.NumberFormatException: For input string: “”</Error><Error id=“2”>edit handler</Error>

Please find below entries for pre-processing tab of content type
sys_imageInfoExtractor()
PSOThumbnailGenerator(uploadfilephoto,img200,200-,720,200,)
sys_CopyParameter(uploadfilephoto_clear,img200_clear)

After following the above mentioned approach, if we remove the main image from the content item, save and preview it (with the respective velocity page template) we did not get autogenerated thumbnail in preview but when we preview the same content item with binary template “BnImg200” (for autogenerated thumbnail), we get autogenerated thumbnail in the preview.

Ideally after following the above mentioned approach, it should not display the autogenerated thumbnail in binary template preview also.

As per the above followed approach we assumed that the autogenerated thumbnail is getting removed from img200 field of content type but it seems the autogenerated thumbnail is also getting stored in some system field which the binary template is utilizing. Please find below the bindings for our binary template i.e. “BnImg200”:

$sys.binary : $sys.item.getProperty(“rx:img200”)
$sys.mimetype : $sys.item.getProperty(“rx:img200_type”)

Please suggest some centralized approach to remove the thumbnails so that it will not get displayed in both binary as well as velocity template preview.

Thanks.[/QUOTE]

Hi Nate,

Thanks for the response. I downloaded the PSOToolkit-SNAPSHOT.ZIP, extracted it and followed the instructions in readme.txt given below:

  1. Removed the existing PSOToolkit-7.x.jar from <Rx root dir>/AppServer/server/rx/deploy/rxapp.ear/rxapp.war/WEB-INF/lib.
  2. Run the install.sh but got following errors while running the script:

$ ./install.sh /cms/Rhythmyx/
: command not found3:
'/install.sh: line 4: syntax error near unexpected token { '/install.sh: line 4:Help() {

Please look into the issue and respond.

Thanks

Hi,

Sorry, I should have put a note in the readme on that. There is a GIT encoding issue on the .sh files with the current snapshot that I haven’t fixed yet.

If you run “dos2unix install.sh” that should solve the error. The problem is that the sh file has Windows style line endings in it.

-n

[QUOTE=vgupta;20787]Hi Nate,

Thanks for the response. I downloaded the PSOToolkit-SNAPSHOT.ZIP, extracted it and followed the instructions in readme.txt given below:

  1. Removed the existing PSOToolkit-7.x.jar from <Rx root dir>/AppServer/server/rx/deploy/rxapp.ear/rxapp.war/WEB-INF/lib.
  2. Run the install.sh but got following errors while running the script:

$ ./install.sh /cms/Rhythmyx/
: command not found3:
'/install.sh: line 4: syntax error near unexpected token { '/install.sh: line 4:Help() {

Please look into the issue and respond.

Thanks[/QUOTE]

Hi Nate,

As suggested, I ran the “dos2unix install.sh” and then run install.sh as result of which new PSOToolkit got installed successfully. I used pso_copyParameter below PSOThumbnailGenerator in the pre-processing tab of content type as shown below:

pso_CopyParameter(uploadfilephoto_clear,img200_clear,)

But while editing the content item i again got Numberformat exception as shown below:

<Error id=“0”>An error occurred processing the query submitted by session id 6246a0eb7955fc5ad1e57025d7d728d9c2369399.</Error>
<Error id=“1”>java.lang.NumberFormatException: For input string: “”</Error>
<Error id=“2”>edit handler</Error>

Please look and suggest.

Thanks.

Try setting the fieldSize / 4th parameter to a value of 4.

The Toolkit is using StringUtils from Apache Commons Lang library for that parameter. Also can you look in the AppServer/server/rx/deploy/rxapp.ear/rxapp.war/WEB-INF/lib folder and check for the file commons-lang-2.4.jar? Specifically I am wondering if there is more than one version of this jar deployed, the version above is from an Out of the Box 7.2.

If you could also check the server log for when that error occurs and paste in the Stack Trace, that will also help me confirm that that parameter is the one throwing the error.

Thanks,

-nate

[QUOTE=vgupta;20792]Hi Nate,

As suggested, I ran the “dos2unix install.sh” and then run install.sh as result of which new PSOToolkit got installed successfully. I used pso_copyParameter below PSOThumbnailGenerator in the pre-processing tab of content type as shown below:

pso_CopyParameter(uploadfilephoto_clear,img200_clear,)

But while editing the content item i again got Numberformat exception as shown below:

<Error id=“0”>An error occurred processing the query submitted by session id 6246a0eb7955fc5ad1e57025d7d728d9c2369399.</Error>
<Error id=“1”>java.lang.NumberFormatException: For input string: “”</Error>
<Error id=“2”>edit handler</Error>

Please look and suggest.

Thanks.[/QUOTE]

Also. I just realized that you said you installed the snapshot. You should not need PSOCopyParameter with that version as I added the fix to the PSOThumbnailGenerator. I’d still like to isolate the PSOCopyParameter exception though. I don’t see that error on the testing instance.

-n

[QUOTE=natechadwick;20794]Try setting the fieldSize / 4th parameter to a value of 4.

The Toolkit is using StringUtils from Apache Commons Lang library for that parameter. Also can you look in the AppServer/server/rx/deploy/rxapp.ear/rxapp.war/WEB-INF/lib folder and check for the file commons-lang-2.4.jar? Specifically I am wondering if there is more than one version of this jar deployed, the version above is from an Out of the Box 7.2.

If you could also check the server log for when that error occurs and paste in the Stack Trace, that will also help me confirm that that parameter is the one throwing the error.

Thanks,

-nate[/QUOTE]

Hi Nate,

Thanks for the reply. I did not get the number format exception after setting the field size (i.e. 4 parameter) value to 4 in pso_CopyParameter. Also, i checked AppServer/server/rx/deploy/rxapp.ear/rxapp.war/WEB-INF/lib folder and there is only single version of commons-lang-2.4.jar. I am not getting any issue in Stack trace now after setting the field size parameter value to 4 in pso_CopyParameter.

Thanks.

Hi Nate,

As suggested, I removed the pso_CopyParameter from the pre-processing tab of content type. If i remove the main image from the content item using “clear” check box, update the item and preview it with some velocity template i don’t get autogenerated thumbnail in velocity template preview but if i preview the same item with some binary template (using binary assembler) then i can still see the old thumbnail in the preview.

Please look into it and suggest.

Thanks.

Hi Nate,

We are aware that solution for “Image clear” issue for auto-generated thumbnail will come in upcoming patches of PSOToolkit. But, if there is any other alternative solution for removing the auto-generated thumbnail from Binary template preview (template using binary assembler) then please suggest.

Thanks

Hi,

I am not sure why this isn’t working for you, I have tested this on a couple of systems here and both the PSOCopyParameter approach with the field_clear technique and the PSOThumbnailGenerator clear the thumbnail. Are you sure there isn’t a typo in the field name in the parameter options? Also definitely check to make sure that there is only one version of the toolkit jar installed in WEB-INF/lib and that the instance was restarted after installing the updated toolkit.

-nate

[QUOTE=vgupta;20818]Hi Nate,

We are aware that solution for “Image clear” issue for auto-generated thumbnail will come in upcoming patches of PSOToolkit. But, if there is any other alternative solution for removing the auto-generated thumbnail from Binary template preview (template using binary assembler) then please suggest.

Thanks[/QUOTE]