I always forget how to do things like this as I do not have to do them very often so I thought I would blog about it.
We've had a couple of projects here at Netsight where customers have required customised image content types in their plone sites. All very easy to do but an issue arrives when you want to be able to use this new content type in Kupu.
Say you created a new Image content type called CustomImage and added one in your plone site. Then you create a new page in your site and want to use this image in that page. To be able to use your new content type in kupu you need to modify new kupu.xml. If you do not already have a modified kupu.xml the easiest way to create one is to got to portal_setup in the zmi and export 'Kupu Settings' then move this into the 'default' folder inside 'profiles' in you content types product.
Add the following line (replace CustomImage with your own content type's name):
<type>CustomImage</type>
into the following location like so:
<resource id="mediaobject" mode="whitelist"> <type>CustomImage</type> <type>Image</type> </resource>
Once you have reinstalled your product (and reindexed the catalog) you should be able to insert an image, that already exists and is your new content type, into a kupu document.
To be able to upload an image from inside kupu you'll need to do another step. You have to override what content type is created when you upload from within kupu. In profiles/default create a new file called contenttyperegistry.xml and add the following code (replacing 'CustomImage' with your image content type name).
<?xml version="1.0"?>
<object name="content_type_registry" meta_type="Content Type Registry">
<predicate name="ATImage_ext" content_type_name="CustomImage"
predicate_type="extension">
<argument value="jpg,jpeg,png,gif"/>
</predicate>
<predicate name="image" content_type_name="CustomImage"
predicate_type="major_minor">
<argument value="image"/>
<argument value=""/>
</predicate>
</object>
Once again after reinstalling your product and reindexing the catalog, you should be able to upload your new custom image content type from within kupu.
I hope this is useful to more people that just me.
Adrian
