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
Comment #2
sam152 commentedComment #3
sam152 commentedComment #4
jibranNice catch. Looks good to me. I think I can add #2554339: Plan for CTools 7.x-1.10 release as related.
Comment #5
jibran@Sam152 can you also update the patch in #2411353: Default value of image field is not shown as well?
Comment #6
sam152 commentedI 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.
Comment #7
Pedro Lozano commentedDoes't this patch have the same effect and it is cleaner?
Comment #8
travis-bradbury commentedI was experiencing this issue as well. Pedro's patch does the job and looks good.
Comment #10
japerryFixed in #2411353: Default value of image field is not shown