? imagefield_captioncredit.patch
Index: imagefield.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imagefield/imagefield.css,v
retrieving revision 1.2
diff -u -p -r1.2 imagefield.css
--- imagefield.css 1 Dec 2006 05:15:57 -0000 1.2
+++ imagefield.css 3 Aug 2007 15:45:18 -0000
@@ -29,4 +29,13 @@ div.imagefield-edit-image-flags div.form
float: right;
}
+div.imagefield-image-credit {
+ padding: 0px;
+ margin-top: -5px;
+ font-size: 10px;
+ font-weight: bold;
+}
+div.imagefield-image-caption {
+
+}
\ No newline at end of file
Index: imagefield.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imagefield/imagefield.install,v
retrieving revision 1.2.4.1
diff -u -p -r1.2.4.1 imagefield.install
--- imagefield.install 18 Apr 2007 21:02:19 -0000 1.2.4.1
+++ imagefield.install 3 Aug 2007 15:45:18 -0000
@@ -73,6 +73,43 @@ function imagefield_update_2() {
return $ret;
}
+/**
+ * Schema change to enable credit and byline tags
+ */
+
+function imagefield_update_3() {
+ $ret = array();
+
+ include_once(drupal_get_path('module', 'content') .'/content.module');
+ include_once(drupal_get_path('module', 'content') .'/content_admin.inc');
+
+ $fields = content_fields();
+
+ foreach ($fields as $field) {
+ switch ($field['type']) {
+ case 'image':
+ $oldcolumns = array(
+ 'fid' => array('type' => 'int', 'not null' => TRUE, 'default' => '0'),
+ 'title' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => "''", 'sortable' => TRUE),
+ 'alt' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => "''", 'sortable' => TRUE),
+ );
+ $newcolumns = array(
+ 'fid' => array('type' => 'int', 'not null' => TRUE, 'default' => '0'),
+ 'title' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => "''", 'sortable' => TRUE),
+ 'alt' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => "''", 'sortable' => TRUE),
+ 'caption' => array('type' => 'text', 'not null' => FALSE, 'sortable' => TRUE), // length irrelevant for non-varchar
+ 'credit' => array('type' => 'varchar', 'length' => 128, 'not null' => FALSE, 'default' => "''", 'sortable' => TRUE),
+ );
+ content_alter_db_field($field, $oldcolumns, $field, $newcolumns);
+ break;
+ }
+ drupal_set_message('altered:
'. print_r($field, true) .''); + } + + + db_query('DELETE FROM {cache}'); + return $ret; +} Index: imagefield.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/imagefield/imagefield.module,v retrieving revision 1.30.2.6.2.22 diff -u -p -r1.30.2.6.2.22 imagefield.module --- imagefield.module 14 Jul 2007 22:36:41 -0000 1.30.2.6.2.22 +++ imagefield.module 3 Aug 2007 15:45:18 -0000 @@ -99,6 +99,8 @@ function imagefield_field_settings($op, 'fid' => array('type' => 'int', 'not null' => TRUE, 'default' => '0'), 'title' => array('type' => 'varchar', length => 255, 'not null' => TRUE, 'default' => "''", 'sortable' => TRUE), 'alt' => array('type' => 'varchar', length => 255, 'not null' => TRUE, 'default' => "''", 'sortable' => TRUE), + 'credit' => array('type' => 'varchar', 'length' => 128, 'not null' => FALSE, 'default' => "''", 'sortable' => TRUE), + 'caption' => array('type' => 'text', 'not null' => FALSE, 'sortable' => TRUE), // length irrelevant for non-varchar ); return $columns; } @@ -309,6 +311,18 @@ function imagefield_widget_settings($op, '#default_value' => $widget['custom_title'] ? $widget['custom_title'] : 0, '#description' => t('Enable custom title text for images. Filename will be used if not checked.'), ); + $form['custom_caption'] = array( + '#type' => 'checkbox', + '#title' => t('Enable custom caption text'), + '#default_value' => $widget['custom_caption'] ? $widget['custom_caption'] : 0, + '#description' => t('Enable custom caption text for images. Will be left blank if not checked'), + ); + $form['custom_credit'] = array( + '#type' => 'checkbox', + '#title' => t('Enable custom credit text'), + '#default_value' => $widget['custom_credit'] ? $widget['custom_credit'] : 0, + '#description' => t('Enable custom photo credit for images. Will be left blank if not checked'), + ); $form['default'] = array( '#type' => 'fieldset', '#title' => t('Default image'), @@ -353,7 +367,7 @@ function imagefield_widget_settings($op, break; case 'save': - return array('max_resolution', 'image_path', 'file_extensions', 'custom_alt', 'custom_title', 'use_default_image', 'default_image'); + return array('max_resolution', 'image_path', 'custom_alt', 'custom_title', 'custom_caption', 'custom_credit', 'teaser_preset', 'body_preset'); } } @@ -542,7 +556,6 @@ function _imagefield_widget_form($node, drupal_add_js('misc/upload.js'); $fieldname = $field['field_name']; - drupal_add_css(drupal_get_path('module', 'imagefield') .'/imagefield.css'); $form = array(); @@ -605,9 +618,10 @@ function _imagefield_widget_form($node, $filename = $file['fid'] == 'upload' ? file_create_filename($file['filename'], file_create_path($field['widget']['image_path'])) : $file['filepath']; } + // purposely don't pass caption or credit in preview mode because it just looks dumb $form[$fieldname][$delta]['preview'] = array( '#type' => 'markup', - '#value' => theme('imagefield_image', $file, $file['alt'], $file['title'], array('width' => '150'), FALSE), + '#value' => theme('imagefield_image', $file, $file['alt'], $file['title'], '', '', array('width' => '150'), FALSE), ); $form[$fieldname][$delta]['description'] = array( @@ -647,6 +661,37 @@ function _imagefield_widget_form($node, ); } + $form[$fieldname][$delta]['credit'] = array( + '#type' => 'hidden', + '#value' => '', + ); + // overwrite with an input field if custom_caption is flagged; + if ($field['widget']['custom_credit']) { + $form[$fieldname][$delta]['credit'] = array( + '#type' => 'textfield', + '#title' => t('Photo Credit'), + '#default_value' => $file['credit'], + '#description' => t('Photographer Credit'), + '#maxlength' => 128, + '#size' => 10, + ); + } + + $form[$fieldname][$delta]['caption'] = array( + '#type' => 'hidden', + '#value' => '', + ); + // overwrite with an input field if custom_caption is flagged; + if ($field['widget']['custom_caption']) { + $form[$fieldname][$delta]['caption'] = array( + '#type' => 'textarea', + '#title' => t('Caption'), + '#default_value' => $file['caption'], + '#description' => t('Photo caption'), + '#rows' => 8, + ); + } + // Special handling for single value fields if (!$field['multiple']) { $form[$fieldname][$delta]['replace'] = array( @@ -660,6 +705,8 @@ function _imagefield_widget_form($node, $form[$fieldname][$delta]['flags']['delete'] = array('#type' => 'value', '#value' => $file['flags']['delete']); $form[$fieldname][$delta]['title'] = array('#type' => 'value', '#value' => $file['title']); $form[$fieldname][$delta]['alt'] = array('#type' => 'value', '#value' => $file['alt']); + $form[$fieldname][$delta]['credit'] = array('#type' => 'value', '#value' => $file['credit']); + $form[$fieldname][$delta]['caption'] = array('#type' => 'value', '#value' => $file['caption']); } if (isset($file['sessionid'])) { $form[$fieldname][$delta]['sessionid'] = array('#type' => 'value', '#value' => $file['sessionid']); @@ -773,7 +820,7 @@ function imagefield_field_formatter($fie $file = $field['widget']['default_image']; } if (!empty($file['filepath'])) { - return theme('imagefield_image', $file, $item['alt'], $item['title']); + return theme('imagefield_image', $file, $item['alt'], $item['title'], $item['caption'], $item['credit']); } } @@ -791,22 +838,22 @@ function _imagefield_file_load($fid = NU return array(); } -function theme_imagefield_view_image($file, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE) { - return theme('imagefield_image', $file, $alt, $title, $attributes , $getsize); +function theme_imagefield_view_image($file, $alt = '', $title = '', $caption = '', $credit = '', $attributes = NULL, $getsize = TRUE) { + return theme('imagefield_image', $file, $alt, $title, $caption, $credit, $attributes , $getsize); } - -function theme_imagefield_edit_image_row($element) { +function theme_imagefield_edit_image_row($element) { $output = '