I’ve recently been working on a nodeapi-based image upload module for 4.7 and introduced it to the dev list. Walkah and Moshe suggested posting the code, so I am putting it here for review.
The image_nodeapi module currently has the following functionality:
- Settings page to determine which nodes should enable image uploads.
- Uses the image functions image_prepare, image_insert and image_update to do all the heavy lifting.
- Allows users to set a caption for the image.
- Default layout of a floated right image with the caption displayed underneath the image on pages.
- Passes the node object to the theme, allowing site admins to over-write presentation of images to fit site specific needs.
- Along these lines, admins could use a case statement in their theme file that would display a different layout for different node types, etc.
nodeapi_image.mysql
--
-- Table structure for table `nodeapi_image`
--
CREATE TABLE nodeapi_image (
nid int(10) unsigned NOT NULL default '0',
caption text,
PRIMARY KEY (nid)
) TYPE=MyISAM
/*!40100 DEFAULT CHARACTER SET utf8 */;
nodeapi_image.module
<?php
// $Id: $
/**
* @file nodeapi_image.module
*/
/**
* implementation of hook menu
*
* This just adds the css file.
*/
function nodeapi_image_menu($may_cache){
if (!$may_cache) {
theme_add_style(drupal_get_path('module', 'nodeapi_image') .'/nodeapi_image.css');