Image fields in field groups have wrong order index

More
7 years 1 month ago #66696 by mcmurdok
I've an image field as a part of an multiple field group with other fields like e.g. 'topic' .
For example, if I generate 3 instances of this field group with each 'topic' and 'image' everything is OK.
In the $item->fields->value
Code:
Array ( [0] => a:4:{s:12:"originalname";s:25:"imageA.jpg";s:4:"desc";s:0:"";s:12:"existingname";s:0:"";s:6:"remove";b:0;} [1] => a:4:{s:12:"originalname";s:29:"imageB.jpg";s:4:"desc";s:0:"";s:12:"existingname";s:0:"";s:6:"remove";b:0;} [2] => a:4:{s:12:"originalname";s:27:"imageC.jpg";s:4:"desc";s:0:"";s:12:"existingname";s:0:"";s:6:"remove";b:0;} )
and for $item->fields->value
Code:
Array ( [0] => Topic A [1] => Topic B [2] => Topic C )
I find everything sorted well.

But if I decide not to choose a picture for example 'Topic B' I get this wrong sorted image field array:
Code:
Array ( [0] => a:4:{s:12:"originalname";s:25:"imageA.jpg";s:4:"desc";s:0:"";s:12:"existingname";s:0:"";s:6:"remove";b:0;} [1] => a:4:{s:12:"originalname";s:27:"imageC.jpg";s:4:"desc";s:0:"";s:12:"existingname";s:0:"";s:6:"remove";b:0;} )
but i expected
Code:
Array ( [0] => a:4:{s:12:"originalname";s:25:"imageA.jpg";s:4:"desc";s:0:"";s:12:"existingname";s:0:"";s:6:"remove";b:0;} [2] => a:4:{s:12:"originalname";s:27:"imageC.jpg";s:4:"desc";s:0:"";s:12:"existingname";s:0:"";s:6:"remove";b:0;} )

So it's not possible to associate the images with the right instance of the multiple field group. For text fields it isn't a problem. If I choose not to fill out the topic field of the second instance I get correct
Code:
Array ( [0] => Topic A [2] => Topic C )

And maybe it's part of the same problem:
Under $item->fields->display and $item->fields->thumbs_src e.g. I get only the values from array index '0' and these aren't inevitably the values of the first instance of the field group as described above.
For now I always have to unserialize the field value ($item->fields->value[$i]) to get the image filename and combine it with the $item->fields->parameters->get('dir'). So it would be nice to get direct access to the values of every instance of a field group.

Regards

Please Log in or Create an account to join the conversation.

More
7 years 1 month ago #66809 by mcmurdok
Hello,
am I wrong or do I want to use these field groups in a wrong way?

Regards

Please Log in or Create an account to join the conversation.

More
7 years 1 month ago #66840 by ggppdk
Hello

this an old bug of older FLEXIcontent versions
if you edit and resave the item with FLEXIcontent v3.1.1

then it should work, does it not ?


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
7 years 3 weeks ago - 7 years 3 weeks ago #66923 by mcmurdok
Hello
sorry for my late answer.
Although it could have been that I still have old data because I updated the system from an older flexicontent it can't be the reason for the bug.
This is because I used this multi-field feature the first time after all upgrade routines and I also tested it with another J3.6.x system with fc3.3.1.
I'll test the bug now with an absolutely new installation.

--- UPDATE ---
Ok, I tested with this results: if I use fieldgroup -> display in category view or item view, it works.
But I need the specific values ($item->fields->value) of the image field which is part of the fieldgroup. And this doesn't still work as discribed above.
In item view I've a values array with [thumbs_src], [display_backend_src], etc., including all instances of the fieldgroup, if also with wrong sorted value.
In category view I've only index [0] of the fieldgroup image field although I have more than one instance of the fieldgroup image.

I hope I wasn't too confusing ;)

Regards
Last edit: 7 years 3 weeks ago by ggppdk.

Please Log in or Create an account to join the conversation.

More
7 years 3 weeks ago #66981 by ggppdk
Hello

test this fix / improvement:
in file:
plugins/flexicontent_fields/image/image.php

Replace
Code:
foreach ($values as $val)
with:
Code:
foreach ($values as $n => $val)

and:
Code:
// ADD some extra (display) properties that point to all sizes, currently SINGLE IMAGE only if ($is_ingroup) { // In case of field displayed via in fieldgroup, this is an array $field->{"display_backend_src"}[] = JURI::root(true).'/'.$srcb; $field->{"display_small_src"}[] = JURI::root(true).'/'.$srcs; $field->{"display_medium_src"}[] = JURI::root(true).'/'.$srcm; $field->{"display_large_src"}[] = JURI::root(true).'/'.$srcl; $field->{"display_original_src"}[] = JURI::root(true).'/'.$srco; } else if ($i==0) { // Field displayed not via fieldgroup return only the 1st value $field->{"display_backend_src"} = JURI::root(true).'/'.$srcb; $field->{"display_small_src"} = JURI::root(true).'/'.$srcs; $field->{"display_medium_src"} = JURI::root(true).'/'.$srcm; $field->{"display_large_src"} = JURI::root(true).'/'.$srcl; $field->{"display_original_src"} = JURI::root(true).'/'.$srco; } $field->thumbs_src['backend'][] = JURI::root(true).'/'.$srcb; $field->thumbs_src['small'][] = JURI::root(true).'/'.$srcs; $field->thumbs_src['medium'][] = JURI::root(true).'/'.$srcm; $field->thumbs_src['large'][] = JURI::root(true).'/'.$srcl; $field->thumbs_src['original'][] = JURI::root(true).'/'.$srco; $field->thumbs_path['backend'][] = JPATH_SITE.DS.$srcb; $field->thumbs_path['small'][] = JPATH_SITE.DS.$srcs; $field->thumbs_path['medium'][] = JPATH_SITE.DS.$srcm; $field->thumbs_path['large'][] = JPATH_SITE.DS.$srcl; $field->thumbs_path['original'][] = JPATH_SITE.DS.$srco;

with
Code:
// ADD some extra (display) properties that point to all sizes, currently SINGLE IMAGE only if ($is_ingroup) { // In case of field displayed via in fieldgroup, this is an array $field->{"display_backend_src"}[$n] = JURI::root(true).'/'.$srcb; $field->{"display_small_src"}[$n] = JURI::root(true).'/'.$srcs; $field->{"display_medium_src"}[$n] = JURI::root(true).'/'.$srcm; $field->{"display_large_src"}[$n] = JURI::root(true).'/'.$srcl; $field->{"display_original_src"}[$n] = JURI::root(true).'/'.$srco; } else if ($i==0) { // Field displayed not via fieldgroup return only the 1st value $field->{"display_backend_src"} = JURI::root(true).'/'.$srcb; $field->{"display_small_src"} = JURI::root(true).'/'.$srcs; $field->{"display_medium_src"} = JURI::root(true).'/'.$srcm; $field->{"display_large_src"} = JURI::root(true).'/'.$srcl; $field->{"display_original_src"} = JURI::root(true).'/'.$srco; } $field->thumbs_src['backend'][$is_ingroup ? $n : $i] = JURI::root(true).'/'.$srcb; $field->thumbs_src['small'][$is_ingroup ? $n : $i] = JURI::root(true).'/'.$srcs; $field->thumbs_src['medium'][$is_ingroup ? $n : $i] = JURI::root(true).'/'.$srcm; $field->thumbs_src['large'][$is_ingroup ? $n : $i] = JURI::root(true).'/'.$srcl; $field->thumbs_src['original'][$is_ingroup ? $n : $i] = JURI::root(true).'/'.$srco; $field->thumbs_path['backend'][$is_ingroup ? $n : $i] = JPATH_SITE.DS.$srcb; $field->thumbs_path['small'][$is_ingroup ? $n : $i] = JPATH_SITE.DS.$srcs; $field->thumbs_path['medium'][$is_ingroup ? $n : $i] = JPATH_SITE.DS.$srcm; $field->thumbs_path['large'][$is_ingroup ? $n : $i] = JPATH_SITE.DS.$srcl; $field->thumbs_path['original'][$is_ingroup ? $n : $i] = JPATH_SITE.DS.$srco;


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
3 years 5 months ago #79508 by mcmurdok
3years later I've got nearly the same problem.
I saw, you updated the image.php so that there aren't anymore the serialized values.
But now, if I use the image field inside a field group, the image field values don't correspondend with the index of the instance of the fieldgroup.
If I don't assign an image to an instance, the following assigned images get the index of the missing one.
The same way as described above. Was your fix part of the last versions of flexicontent or just for me?
Can you implement this fix to the next version of image field in flexicontent?

Regards

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.521 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline