-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Image crops lost when editing image title #21
Comments
|
until we don't want to change plone core modules, the only solution is to make a method which restores/resaves the scale on ObjectModifiedEvent Edit by @laulaz (2017-02-15) :Here is the code to fix this bug in Plone 4 without touching in your configure.zcml :
in events.py :
|
@jpgimenez this is going to bite us when we deprecate our image tile in favor of the standard tile (collective/collective.cover#81) |
crops are also lost when image is copied. <monkey:patch
description="Patch plone.scales to create cropped images"
class="plone.scale.storage.AnnotationStorage"
original="scale"
replacement=".storage.patched_scale"
preserveOriginal="true"
/> Several ugly things are happening down below. I'd love to see an adapter for plone.scales which queries for a factory how to create crops. What do you think about that? from plone.app.imagecropping import PAI_STORAGE_KEY
from plone.app.imagecropping.interfaces import IImageCroppingUtils
from zope.annotation.interfaces import IAnnotations
from zope.component import getMultiAdapter
def patched_scale(self, factory=None, **parameters):
"""This is a really dirty hack to re-create blob files if a
cropping information was stored in object annotation.
"""
info = self._old_scale(factory, **parameters)
# XXX: That's very nasty
if not factory.func_name == 'crop_factory' \
and (parameters.get('width') != info.get('width') or
parameters.get('height') != info.get('height')):
cropped = IAnnotations(self.context).get(PAI_STORAGE_KEY)
if not cropped:
return info
utils = IImageCroppingUtils(self.context)
cropping_view = getMultiAdapter(
(self.context, self.context.REQUEST), name='crop-image')
for fieldname in utils.image_field_names():
for image_name, box in cropped.items():
scale = image_name.split('_').pop()
cropping_view._crop(fieldname, scale, box)
return info |
any news on this issue? |
just stumbled over a discussion on plone.scale (plone/plone.scale#3) which is related to this |
@tomgross and i fixed this ticket in #38 for dexterity, this currently means to implement another interface. @joka as dexterity pro: are you ok with that? personally i'd love to see that we can find a way to make dexterity content that implement IImageCropping also implement IImageCroppingScale. if we can't find a way to make that happen, we should think about moving this interface out of the browser package to plone.app.imagecropping.interfaces and add some documentation to the readme |
@saily reading through the comments here i see you mentioned copying an image too. i did not test that yet. would be great to get your feedback if this fixes your issues too. |
Let's write a test to check that, should be easy to implement. i'll try to find some time for that... anyway, thanks for fixing |
This refs IMIO #14901 This is already fixed in Plone 5 but not in Plone 4 See collective/plone.app.imagecropping#21
crops get invalidated when the image title/description or other metadata is changed.
this should only happen if the image file itself gets changed.
to reproduce:
it's important to mention that this only happens for scales.scale and not for the plone.app.imaging traverser:
test1.jpg/@@images/8689307d-f3e7-42c5-9134-f77f6e704cfe.jpeg
will show the scaled imagetest1.jpg/image_frontpage
will still show the cropped imagedid not yet investigate if this bug belongs to imagecropping or plone.scale or plone.app.imaging
The text was updated successfully, but these errors were encountered: