Field offsets no longer work correctly after upgrading to 7.x-1.9. The issue with array_slice is that it preserves the keys, so if you are offsetting by 5 the field deltas are keyed starting from 5, causing later rendering to be tripped up in template_preprocess_field:

$variables['items'] = array();
  foreach ($element['#items'] as $delta => $item) {
    if (!empty($element[$delta])) {
      $variables['items'][$delta] = $element[$delta];
    }
  }
-    $new_values = array();
-    for ($i = 0; $i < $delta_limit; $i++) {
-      $new_delta = $offset + $i;
-
-      if (isset($all_values[$new_delta])) {
-        $new_values[] = $all_values[$new_delta];
-      }
-    }
-
-    $all_values = $new_values;
+    $all_values = array_slice($all_values, $offset, $limit, TRUE);

Comments

Sam152 created an issue. See original summary.

sam152’s picture

Issue summary: View changes
StatusFileSize
new13.97 KB
sam152’s picture

Status: Active » Needs review
StatusFileSize
new642 bytes
jibran’s picture

Version: 7.x-1.9 » 7.x-1.x-dev
Status: Needs review » Reviewed & tested by the community
Related issues: +#2554339: Plan for CTools 7.x-1.10 release

Nice catch. Looks good to me. I think I can add #2554339: Plan for CTools 7.x-1.10 release as related.

jibran’s picture

@Sam152 can you also update the patch in #2411353: Default value of image field is not shown as well?

sam152’s picture

I don't mind re-rolling either patch depending on the order they get committed. Don't want feedback in one to hold up the other.

Pedro Lozano’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new696 bytes

Does't this patch have the same effect and it is cleaner?

travis-bradbury’s picture

Status: Needs review » Reviewed & tested by the community

I was experiencing this issue as well. Pedro's patch does the job and looks good.

  • japerry committed 2e64485 on 7.x-1.x authored by maximpodorov
    Issue #2411353, #2555083 by maximpodorov, Sam152, Pedro Lozano: Default...
japerry’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.