Question

Part of this question is already solved with another stackoverflow question but it seems that it doesn't clean up everything.

The steps are:

  • create a document with an image field
  • see that the blobstorage has one file
  • open a view with a scaled version of that image
  • see that the blobstorage now has two files, the image and the scaled image
  • do, as suggested on the other question, a zeopack with 0 days
  • see that there is still one blob on blobstorage, the scaled image

So the question is: how can one remove also this scaled images from blobstorage?

I tried running zeopack twice without success, the scaled blob is still around.

UPDATE: as vangheem pointed out, that does not happen for Archetypes Image content types. Still, this question remains valid, as for a Dexterity-based content types that have an image field.

The scales are only removed if you remove the document, which is not my use-case, I just want to remove the image (image credits have expired and the image can not be shown anymore).

Was it helpful?

Solution 2

Found it!

To remove the scales you actually have to remove the plone.scale annotation:

# assume 'document' is a Dexterity-based content type that has a NamedBlobImage field 
from zope.annotation.interfaces import IAnnotations
annotations = IAnnotations(document)
if 'plone.scale' in annotations:
    del annotations['plone.scale']
if getattr(document, 'image', None) is not None and document.image is not None:
    del document.image
    document.reindexObject()

OTHER TIPS

Deleting the content item should delete its scales also.

I just testing in plone 4.2.4. Here were my steps:

  1. delete existing blobstorage and filestorage
  2. start up plone
  3. create new site
  4. add image, see that 2 blobstorage files are created. One the original, another the one scale that has been created so far
  5. delete the image, both files are still in blobstorage for undo support
  6. pack the database to 0 days, both files are now removed from blobstorage

So everything seems to be working correctly.

In your post you mention that you're creating a document. If you means News Item, those images aren't stored in blobstorage.

Now, if you have a custom content type where you have an image field and you're just trying to delete the image field and the scales generated from that field, but not delete the entire type, you'll need to delete the scales manually. I think it'll be something like this:

del doc.__blob_scales['image']['preview']
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top