Reputation: 2558
Part of this question is already solved with another stackoverflow question but it seems that it doesn't clean up everything.
The steps are:
zeopack
with 0 daysSo 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).
Upvotes: 1
Views: 470
Reputation: 2558
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()
Upvotes: 2
Reputation: 3293
Deleting the content item should delete its scales also.
I just testing in plone 4.2.4. Here were my steps:
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']
Upvotes: 2