[Plone-UI] Re: [Plone-Users] change plone images sizes

Espen Moe-Nilssen espen at medialog.no
Mon Nov 17 09:19:21 UTC 2008


Hi

I found the validator described as this:

isMaxSize 	Tests if an upload, file or something supporting len() is  
smaller than a given max size value. 	Tests against a maxsize  
attribute on the field

Is this using a default (set in zope or something) size or can it be  
set, something like:

isMaxSize (value} ?



Den 13. nov. 2008 kl. 18.17 skrev Espen Moe-Nilssen:

>
>
>> There is a validator for this called isMaxSize.
>>
>> You can find more information about validators from the Validator  
>> Reference
>> available here:
>>
>> http://plone.org/documentation/manual/archetypes-developer-manual/ 
>> fields/ref
>> erencemanual-all-pages
>>
>> Shows you how to use them and gives a list of them.
>>
>> -- 
>> Christopher Warner
>> Manager, Content Management Systems
>> New York Media | 75 Varick St, 4th Fl
>> New York, NY 10013
>> phone: 212.508.0542
>> cell: 646.334.6780
>>
>>
>>
>> On 11/13/08 9:59 AM, "Espen Moe-Nilssen" <espen at medialog.no> wrote:
>>
>>> While "we are at it":
>>>
>>> Is there a way to avoid large files (I am thinking about Mb not  
>>> pixels here)?
>>>
>>>
>>>
>>> Den 13. nov. 2008 kl. 15.17 skrev Harald Friessnegger:
>>>
>>>> thx again christopher, thx daniel
>>>>
>>>>
>>>> although its a larger project i decided to monkeypatch cause we  
>>>> don't need
>>>> the default image sizes anyway.
>>>> the only thing one needs to take care is that the sizes needed  
>>>> by plone
>>>> (preview/tile/etc) still are available in more or less similar  
>>>> sizes.
>>>>
>>>>
>>>>
>>>>
>>>> i played around a bit to find out what happens if you already  
>>>> have lots of
>>>> images in your portal and change image sizes. or if you find out  
>>>> that you
>>>> need to change a size later on.
>>>> this might be useful information for others:
>>>>
>>>>
>>>>
>>>> assume we already have a lot of images on the portal that used  
>>>> atctimage
>>>> defaults (no max_size and sizes from listing to large)
>>>> now we monkeypatch the imagefield:
>>>> field.sizes = {'custom':(10,10), 'sizes':(20,20), 'here':(30,30)}
>>>> field.max_size = (150,150)
>>>>
>>>> plone/old-image/ will render the image in it's orginial size  
>>>> (even larger
>>>> than 150,150)
>>>> plone/old-image/image_preview image_tile etc are no longer  
>>>> available since
>>>> the scale is not defined for image anymore
>>>> plone/old-image/image_custom is not available either
>>>>
>>>> freshly uploaded images will have a maximum size of 150px by  
>>>> 150px and will
>>>> be available in the new scales.
>>>>
>>>>
>>>> recreate scales
>>>> ---------------
>>>>
>>>> go to /plone/portal_atct and click the `Image scales` tab. Push the
>>>> `recreate` button to make the tool search for all images and  
>>>> recreate their
>>>> scales.
>>>>
>>>> after recreating image scales, all images on the portal are  
>>>> available in our
>>>> monkeypatched scales.
>>>>
>>>> the max_size does not get touched here, so our old-image is  
>>>> still available
>>>> in it's original size rather than downscaled to 150x150.
>>>>
>>>> change sizes
>>>> ------------
>>>>
>>>> now we change our sizes to the following values and restart the  
>>>> server::
>>>>
>>>>   field.sizes = {'custom':(100,100), 'sizes':(200,200), 'here': 
>>>> (300,300)}
>>>>
>>>> plone/old-image/image_custom still returns a 10x10 pixel image.
>>>> so we recreate the scales again.
>>>>
>>>> after that
>>>> plone/old-image/image_here will return a 100x100 pixel image and
>>>> plone/new-image/image_here will return a 150x150 pixel image  
>>>> since this is
>>>> it's maximum size
>>>>
>>>>
>>>>
>>>> regards, fRiSi
>>>>
>>>> Daniel Widerin wrote:
>>>>
>>>>
>>>>> hi fRiSi
>>>>>
>>>>>
>>>>>> ...
>>>>>> A) monkeypath
>>>>>>
>>>>>> at product initialization do something like
>>>>>>
>>>>>> from Products.ATContentTypes.content.image import ATImageSchema
>>>>>>
>>>>>> ATImageSchema['image'].sizes = {'custom':(10,10), 'sizes': 
>>>>>> (20,20), 'here'
>>>>>> (30,30)}
>>>>>>
>>>>>> and be aware that this changes the image size for all portal  
>>>>>> within this
>>>>>> zope instanze (which is no problem for my usecase)
>>>>>>
>>>>>
>>>>> since every site gets its own instance using buildout we use
>>>>> monkeypatches to modify image sizes for atimage.
>>>>> note: atnewsitem and atimage use different sizes dicts. if you  
>>>>> want
>>>>> atnewsitem to get your image_sizes, you will have to patch it too.
>>>>>
>>>>>
>>>>>>
>>>>>> B) edit image.py directly
>>>>>>
>>>>>> bad since i need to re-do this whenever i update or re-run  
>>>>>> buildout
>>>>>>
>>>>>> C) use a custom type
>>>>>>
>>>>>> subclass ATImage and change the sizes to my needs.
>>>>>> set global_allow = False for ATImage to deactivate it on the  
>>>>>> portal
>>>>>>
>>>>>> the only question i have is how to tell kupu to use my new  
>>>>>> type when
>>>>>> uploading images via the editor.
>>>>>> maybe setting my new CustomImage as the only media type and  
>>>>>> remove the
>>>>>> Image in kupu_library_tool/zmi_resource_types?
>>>>>>
>>>>>>
>>>>>
>>>>> for large projects with custom image types i would subclass  
>>>>> ATImage, but
>>>>> if you only want to change the sizes for a mini-site, use A)
>>>>>
>>>>>
>>>>>>
>>>>>> would you guys prefere C) over A)??
>>>>>>
>>>>>> regards, fRiSi
>>>>>>
>>>>>
>>>>> saily
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------ 
>>>>> -------
>>>>> This SF.Net email is sponsored by the Moblin Your Move Developer's
>>>>> challenge Build the coolest Linux based applications with  
>>>>> Moblin SDK & win
>>>>> great prizes Grand prize is a trip for two to an Open Source event
>>>>> anywhere in the world
>>>>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>>>>>
>>>>
>>>> -- 
>>>> Webmeisterei GmbH - Büro für Netzfragen
>>>> Tel: +43 5572 908877,  Fax: +43 5572 908877-66
>>>> Schmelzhütterstraße 26a, A-6850 Dornbirn
>>>> http://www.webmeisterei.com
>>>>
>>>>
>>>> ------------------------------------------------------------------- 
>>>> ------
>>>> This SF.Net email is sponsored by the Moblin Your Move  
>>>> Developer's challenge
>>>> Build the coolest Linux based applications with Moblin SDK & win  
>>>> great prizes
>>>> Grand prize is a trip for two to an Open Source event anywhere  
>>>> in the world
>>>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>>>> _______________________________________________
>>>> Plone-Users mailing list
>>>> Plone-Users at lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/plone-users
>>>>
>>>
>>>
>>>
>>> -------------------------------------------------------------------- 
>>> -----
>>> This SF.Net email is sponsored by the Moblin Your Move  
>>> Developer's challenge
>>> Build the coolest Linux based applications with Moblin SDK & win  
>>> great prizes
>>> Grand prize is a trip for two to an Open Source event anywhere in  
>>> the world
>>> http://moblin-contest.org/redirect.php?banner_id=100&url=/
>>
>
>
> -- 
> Espen Moe-Nilssen
> Grieg Medialog AS

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.plone.org/pipermail/plone-ui/attachments/20081117/25696853/attachment.html>


More information about the UI mailing list