Recomputing image scales?

We have two Plone 5.1 sites - one with AT and one with Dexterity.
In both cases we need to clear and recompute the scales for all images. Is there an unique API for that?

Andreas

ok, going to clear the plone.scale annotation manually

Afaik the modified date is part of the key calculated. So, setting a new modified date should do it.

1 Like

@zopyx Thank you!

import transaction 
from zope.annotation import IAnnotations 
from zope.component.hooks import setSite 

KEY = 'plone.scale' 

site = app.plone_portal 
setSite(site) 
catalog = site.portal_catalog 

query = dict(portal_type=['Image']) 

for brain in catalog(**query): 
  obj = brain.getObject() 

  annos = IAnnotations(obj) 
  if KEY in annos: 
      print(obj.absolute_url(), 'SCALE REMOVED') 
      del annos[KEY] 
  else: 

      print(obj.absolute_url(), 'no SCALES found') 

transaction.commit()
4 Likes