diff --git a/views/theme/views_views_json_style.theme.inc b/views/theme/views_views_json_style.theme.inc index da61e45..cec5a49 100644 --- a/views/theme/views_views_json_style.theme.inc +++ b/views/theme/views_views_json_style.theme.inc @@ -50,7 +50,15 @@ function template_preprocess_views_views_json_style_simple(&$vars) { } else { $content = array(); - foreach ($field->content as $n => $oc) $content[$n] = ($plaintext_output ? strip_tags($oc) : $oc); + foreach ($field->content as $n => $oc) { + if (is_array($oc)) { + foreach ($oc as $key => $value) { + $content[$n][$key] = ($plaintext_output ? strip_tags($value) : $value); + } + } else { + $content[$n] = ($plaintext_output ? strip_tags($oc) : $oc); + } + } } } elseif ($options["field_output"] == "raw") { @@ -60,7 +68,15 @@ function template_preprocess_views_views_json_style_simple(&$vars) { } else { $content = array(); - foreach ($field->raw as $n => $oc) $content[$n] = $plaintext_output ? strip_tags($oc) : $oc; + foreach ($field->raw as $n => $oc) { + if (is_array($oc)) { + foreach ($oc as $key => $value) { + $content[$n][$key] = ($plaintext_output ? strip_tags($value) : $value); + } + } else { + $content[$n] = ($plaintext_output ? strip_tags($oc) : $oc); + } + } } } diff --git a/views_json.module b/views_json.module index 6ddd2f4..438ae2e 100644 --- a/views_json.module +++ b/views_json.module @@ -180,9 +180,23 @@ function _views_json_render_fields($view, $row) { } } else { - if (preg_match("/]+>/i", $field_output, $img_match)) { - if (preg_match('/(src)="([^"]*)"/i', $img_match[0], $src_match)) - $field_output = ($src_match[2]); + if (preg_match_all("/]+>/i", $field_output, $img_matches)) { + if ( sizeof( $img_matches[0] ) > 1 ) { + $field_output = array(); + $field_is_multiple = TRUE; + foreach ( $img_matches[0] as $i => $img_match ) + if (preg_match('/(src)="([^"]*)"/i', $img_match, $src_match)) { + if (preg_match('/(alt)="([^"]*)"/i', $img_match, $alt_match)) { + $field_output[$i]['src'] = ($src_match[2]); + $field_output[$i]['alt'] = ($alt_match[2]); + } else { + $field_output[$i] = ($src_match[2]); + } + } + } else { + if (preg_match('/(src)="([^"]*)"/i', $img_matches[0][0], $src_match)) + $field_output = ($src_match[2]); + } } }