Api documentation

Documention of the API for http://drupal.org/project/wysiwyg_imageupload

Submodule-API

If you want to extend the image-detail form, e.g. adding new meta data like a description field or a node-reference and so forth, you can use a submodule. the hooks below cann be used to easily alter that form and implement new meta data. Just have a look at the lightbox integration submodule which covers nearly all usecases.

Often you only need

  1. hook_form_alter
  2. hook_wysiwyg_imageupload_entity_save

Thats pretty easy and should not take you more then 30 lines :)

Theming

theme_wysiwyg_imageupload_render_image_entity($img_obj, $arguments)

Theme the whole entity for viewing in a node

theme_wysiwyg_imageupload_render_image($img_obj, $arguments)

Theme the image itself for viewing in a node. It will be embeded into the container

theme_wysiwyg_imageupload_render_meta($img_obj,$arguments)

Theme the meta-data which should be show on node-view. Title and so forth.

theme_wysiwyg_imageupload_render_container($image,$meta,$img_obj,$arguments)

Theme the container with the rendered image and meta-data

theme_wysiwyg_imageupload_render_image_wysiwyg($img_obj, $arguments = array())

Here you can render the image for the WYSIWYG editor. Please dont change this until you exactly know what you do!!

Hooks and alter

hook_wysiwyg_imageupload_image_entity_attached_alter(&$img_obj)

After the node / comment has been created and the inline images have been "attached" (relation is has been build) you can finally react on this event with your code. E.g. convert the path to be private or whatever.

hook_wysiwyg_imageupload_entity_save_alter(&$img_obj)

This hook is called when a new img_obj has been just inserted into the database, filled with all the details. You can alter those things, convert them or e.g. create a node for each image. The main difference to *_entity_attached is, that you dont have the relation yet, so you probably cant relate to the parent yet.

hook_wysiwyg_imageupload_file_uploaded_alter(&$file)

This hook is called when a new file has been just inserted into the database (uploaded). The file has not been assigend to an inline-entity ( iid ) yet, this will happen in hook_wysiwyg_imageupload_image_entity_created_alter. Its just the file.

hook_wysiwyg_imageupload_dest_path_alter(&$path)

You can alter the path for uploading a file using this hook. $path is already expanded to the current file directory + our relative upload root + user path (if present ). After this hook, the file gets uploaded.

hook_wysiwyg_imageupload_rendered_image_alter($img)

You get passed the image rendered by theme_wysiwyg_imageupload_render_image and you can alter it. E.g. the lightbox integration is embedding it into a a-href

hook_wysiwyg_imageupload_image_attribute_alter($attributes)

Change the attributes added to the image ( in the imagecache theme method ).