From 4d2d5aa5e50b9a31e5a11012ab41529207f6d76f Mon Sep 17 00:00:00 2001 From: Kevin Kaland <kevin@wizonesolutions.com> Date: Sun, 29 Jul 2012 10:39:58 -0700 Subject: [PATCH] Issue #1589854: Ensure field on node is set. --- fillpdf.module | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/fillpdf.module b/fillpdf.module index ded5079..e3a5d0f 100644 --- a/fillpdf.module +++ b/fillpdf.module @@ -360,17 +360,19 @@ function fillpdf_merge_pdf($fid, $nids = NULL, $webform_arr = NULL, $sample = NU $left_side = strpos($obj->value, '[stamp:') + 7; $right_side = strpos($obj->value, ']'); $field_name = substr($obj->value, $left_side, $right_side - $left_side); - $image_path = $node->{$field_name}[$node->language][0]['uri']; - $transform_string = FALSE; - $fields[$obj->pdf_key] = '{image}' . drupal_realpath($image_path); - $image_path_info = pathinfo(drupal_realpath($image_path)); - // Store the image data to transmit to the remote service if necessary - $file_data = file_get_contents(drupal_realpath($image_path)); - if ($file_data) { - $image_data[$obj->pdf_key] = array( - 'data' => base64_encode($file_data), - 'filenamehash' => md5($image_path_info['filename']) . '.' . $image_path_info['extension'], - ); + if (isset($node->{$field_name}[$node->language])) { + $image_path = $node->{$field_name}[$node->language][0]['uri']; + $transform_string = FALSE; + $fields[$obj->pdf_key] = '{image}' . drupal_realpath($image_path); + $image_path_info = pathinfo(drupal_realpath($image_path)); + // Store the image data to transmit to the remote service if necessary + $file_data = file_get_contents(drupal_realpath($image_path)); + if ($file_data) { + $image_data[$obj->pdf_key] = array( + 'data' => base64_encode($file_data), + 'filenamehash' => md5($image_path_info['filename']) . '.' . $image_path_info['extension'], + ); + } } } } -- GitLab