|
1 | 1 |
|
2 | | -# Upload and Manage Related Images and Attachments |
| 2 | +# collective.behavior.relatedmedia |
3 | 3 |
|
| 4 | +A Plone Dexterity behavior that lets editors upload, manage, and display related |
| 5 | +images and file attachments directly on content items — without leaving the edit |
| 6 | +form. |
4 | 7 |
|
5 | | -This packages adds a dexterity behavior to upload and manage related images and attachments for rich media pages. |
| 8 | +## Features |
6 | 9 |
|
| 10 | +- **Dexterity behavior** — attach the behavior to any content type via the |
| 11 | + control panel or ZCML; no custom content type required. |
| 12 | +- **Dedicated edit tab** — a *Related Media* tab appears on every content item |
| 13 | + that has the behavior enabled. |
| 14 | +- **Inline upload & selection** — editors can upload new files or pick existing |
| 15 | + Plone content objects through the relation widget; relation type (image vs. |
| 16 | + attachment) is determined automatically from the file's MIME type. |
| 17 | +- **Drag-and-drop ordering** — items inside the widget can be reordered via |
| 18 | + drag-and-drop; titles are editable inline. |
| 19 | +- **Configurable media container** — uploaded files are stored in a dedicated |
| 20 | + folder whose path is defined in the *Related Media Settings* control panel. |
| 21 | + Supports `plone.app.multilingual` (language-independent assets folder) and |
| 22 | + per-object sub-containers. |
| 23 | +- **Viewlets for display** — two viewlets render the media on the content view: |
| 24 | + - `collective.behavior.related_images` (default: `plone.belowcontenttitle`) |
| 25 | + - `collective.behavior.related_attachments` (default: `plone.belowcontentbody`) |
| 26 | +- **Inline gallery via TinyMCE** — a toolbar button lets editors embed an image |
| 27 | + gallery directly inside the rich-text body; placement, image selection, and |
| 28 | + order are fully configurable without leaving the editor. |
| 29 | +- **Configurable image scales** — default scales for thumbnails, preview images, |
| 30 | + and overlay images are set globally in the control panel. |
| 31 | +- **Gallery CSS classes** — a registry-controlled vocabulary provides the |
| 32 | + available CSS classes for galleries; a default class can be pre-selected. |
7 | 33 |
|
8 | | -## Install |
9 | 34 |
|
10 | | -Add to buildout configuration or ``pip install collective.behavior.relatedmedia``. |
| 35 | +## Installation |
11 | 36 |
|
12 | | -Enable it in Plone Add-on controlpanel. |
| 37 | +``` |
| 38 | +pip install collective.behavior.relatedmedia |
| 39 | +``` |
13 | 40 |
|
| 41 | +or add the egg to your buildout configuration, then enable the add-on in the |
| 42 | +Plone **Add-ons** control panel. |
14 | 43 |
|
15 | | -## Configure |
16 | 44 |
|
17 | | -There is a ``Related Media Settings`` controlpanel in the Add-on configuration section. |
| 45 | +## Configuration |
18 | 46 |
|
19 | | -Make sure you set a valid ``Media Container`` path where all the media is stored. |
| 47 | +Open **Site Setup → Add-on Configuration → Related Media Settings** and: |
20 | 48 |
|
| 49 | +1. Set a valid **Media Container** path (relative to the site root or navigation |
| 50 | + root) where uploaded files will be stored. |
| 51 | +2. Optionally enable **Create Media Container in Assets Folder** if you use |
| 52 | + `plone.app.multilingual` and want language-independent storage. |
| 53 | +3. Adjust the default image scales and gallery CSS classes to match your theme. |
21 | 54 |
|
22 | | -## Edit |
23 | 55 |
|
24 | | -When you edit a Page go to the tab ``Related Media``. |
| 56 | +## Usage |
25 | 57 |
|
26 | | -In the relateditems widgets you can select existing content from your page, or you upload |
27 | | -new content via the uploader. Relation type is selected via the mimetype of the media. |
28 | | -You can change the titles of the relations in an input field and rearrange the order |
29 | | -within the widget via drag/drop. |
| 58 | +### Adding media to a content item |
30 | 59 |
|
| 60 | +1. Open the content item in edit mode. |
| 61 | +2. Switch to the **Related Media** tab. |
| 62 | +3. Use the *Related Images* widget to upload new images or select existing ones. |
| 63 | + Use the *Related Attachments* widget for non-image files. |
| 64 | +4. Reorder items by dragging, edit titles inline, then save. |
31 | 65 |
|
32 | | -## View |
| 66 | +### Embedding a gallery in the rich-text body |
33 | 67 |
|
34 | | -The related media viewlets (image, attachment) are defined by: |
| 68 | +1. Place the cursor in the text where the gallery should appear. |
| 69 | +2. Click the **Gallery** icon in the TinyMCE toolbar. |
| 70 | +3. Select the images and choose a gallery style; drag-and-drop to reorder. |
| 71 | +4. To modify an existing gallery, click inside the preview block and open the |
| 72 | + toolbar icon again. |
35 | 73 |
|
36 | | -- ``collective.behavior.related_images`` -> plone.belowcontenttitle |
37 | | -- ``collective.behavior.related_attachments`` -> plone.belowcontentbody |
| 74 | +> **Note:** If you embed a gallery in the text body, disable the |
| 75 | +> *Show images in viewlet* checkbox to avoid rendering images twice. |
| 76 | +> Images added to the behavior *after* inserting the gallery must be added to |
| 77 | +> the TinyMCE gallery manually. |
38 | 78 |
|
39 | 79 |
|
40 | | -Feel free to override the placement in your package zcml for example:: |
| 80 | +## Overriding viewlet placement |
41 | 81 |
|
42 | | - <include package="collective.behavior.relatedmedia" /> |
43 | | - <configure package="collective.behavior.relatedmedia"> |
44 | | - <browser:viewlet |
45 | | - name="collective.behavior.related_images" |
46 | | - for="*" |
47 | | - manager="plone.app.layout.viewlets.interfaces.IAboveContentTitle" |
48 | | - template="widget_images_display.pt" |
49 | | - permission="zope2.View" /> |
50 | | - </configure> |
| 82 | +```xml |
| 83 | +<include package="collective.behavior.relatedmedia" /> |
| 84 | +<configure package="collective.behavior.relatedmedia"> |
| 85 | + <browser:viewlet |
| 86 | + name="collective.behavior.related_images" |
| 87 | + for="*" |
| 88 | + manager="plone.app.layout.viewlets.interfaces.IAboveContentTitle" |
| 89 | + template="widget_images_display.pt" |
| 90 | + permission="zope2.View" /> |
| 91 | +</configure> |
| 92 | +``` |
51 | 93 |
|
52 | | -## TinyMCE Template |
53 | 94 |
|
54 | | -We provide a TinyMCE toolbar icon to enable gallery placement inside the richtext editor:: |
55 | | - |
56 | | -- create a new paragraph in your text where you want to place the gallery. |
57 | | -- Click on the Gallery Icon in the toolbar |
58 | | -- Choose the images you want inside your gallery. You can drag/drop reorder the images too. |
59 | | -- Edit an existing gallery by clicking inside the preview block and click the toolbar icon again. |
60 | | - |
61 | | -NOTES: |
62 | | - |
63 | | -- make sure you disable the checkbox "Show images in viewlet" to prevent double rendered gallery. |
64 | | -- When you add related images after you've inserted a gallery in TinyMCE you need to edit it again |
65 | | - and add the new images manually. |
66 | | - |
67 | | - |
68 | | -## Author |
| 95 | +## Authors |
69 | 96 |
|
70 | 97 | - Peter Mathis [petschki] |
71 | 98 |
|
72 | | - |
73 | 99 | ## Contributors |
74 | 100 |
|
75 | 101 | - Peter Holzer [agitator] |
0 commit comments