Skip to content

Instantly share code, notes, and snippets.

@bangpound
Created July 31, 2014 04:57
Show Gist options
  • Save bangpound/fb2b942df603c13692d5 to your computer and use it in GitHub Desktop.
Save bangpound/fb2b942df603c13692d5 to your computer and use it in GitHub Desktop.
diff --git a/pdf_to_image.module b/pdf_to_image.module
index cfab8c9..d2d1432 100644
--- a/pdf_to_image.module
+++ b/pdf_to_image.module
@@ -59,7 +59,7 @@ function pdf_to_image_field_widget_settings_form($field, $instance) {
$options = array();
foreach ((array) $fields as $field) {
$field_info = field_info_field($field['field_name']);
- if ($field_info['type'] == 'image') {
+ if (in_array($field_info['type'], array('file', 'image'))) {
$options[$field['field_name']] = $field['label'];
}
}
@@ -547,6 +547,13 @@ function pdf_to_image_generate_process_attach($success, $results, $operations) {
$field_name = $results['params']['image']['field']['field_name'];
$entity_id = $results['params']['entity_id'];
$entity_type = $results['params']['entity_type'];
+ $defaults = array();
+ if ($results['params']['image']['field']['type'] == 'file') {
+ $defaults = array(
+ 'display' => !empty($results['params']['image']['field']['settings']['display_default']) ? 0 : 1,
+ 'description' => '',
+ );
+ }
if (isset($entity_id) && is_numeric($entity_id)) {
// Don't use the entity as given, load it again as things may have happened
@@ -560,7 +567,7 @@ function pdf_to_image_generate_process_attach($success, $results, $operations) {
ksort($results['files'], SORT_NUMERIC);
foreach ($results['files'] as $file) {
#$entity->{$field_name}[$field_lang][]['fid'] = $file->fid;
- $entity->{$field_name}[$field_lang][] = (array) $file;
+ $entity->{$field_name}[$field_lang][] = (array) $file + $defaults;
}
watchdog('pdf_to_image', 'Attached converted images to content.', array(), WATCHDOG_INFO);
$saved = pdf_to_image_entity_save($entity_type, $entity);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment