Closed (fixed)
Project:
PhotoSwipe - Responsive JavaScript Modal Image Gallery
Version:
5.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
10 Oct 2023 at 14:54 UTC
Updated:
26 Oct 2023 at 07:54 UTC
Jump to comment: Most recent


Comments
Comment #2
thomas.frobieterComment #3
anybodyThanks, that looks like a bug in the implementation. I guess it should never ever render the label.
Comment #4
thomas.frobieterAgreed, getting the field->getValue() or field->value should fix this.
Comment #6
anybody@thomas.frobieter exactly. I implemented that, please try if it returns the expected results.
This is kind of a breaking change, but the previous implementation doesn't make a lot of sense to me and we shouldn't make this more complicated by allowing to select a view mode etc.
From my perspective the value is what we want.
@Grevil: Please review and checked if the output runs through Twig. Otherwise, we need to ensure that the value is properly escaped for security reasons!
Comment #8
anybodyI added a second option, which might be more intentional, as I saw the lines before. It looks to me as if the view mode parameter was entirely forgotten before, so the field was always rendered in full?
Not yet sure how to proceed here perfectly.
a) Use MR104
b) Use MR105
c) Use MR105 and add another view mode for "field value" and rename the existing to "field in viewmode" or sth. like that.
Opinions?
Comment #9
thomas.frobieterThat's a good point... if this relies on the view mode configuration, what happens if you don't want to show the caption field outside the pswp layer? in other words, if the field display is disabled.
What about using the (escaped) raw value? The only case I can think of where a field formatter makes sense for the caption field is to use something like smart-trim to shorten the text. BUT, this also has the downside that the configuration is the same as the regular output of the caption field when printed elsewhere.
So +1 for using the escaped raw value from the entity, not the one from the render array.
Comment #10
anybody@Grevil:
I'd vote for MR!104 plus
- security check (see #6)
- Removal of the strange view mode code above
- Use a common prefix like "Field value: " + human readable field name + (machine name) if not too complicated
- Set title as default value for this selection
Rendering the field seems super strange and incomplete this way, as the selected field might
- be hidden or configured differently in the default view mode
- have a label (like described in the IS)
- have complex HTML
So the label is the better solution.
Please also have a look at code changes (blame) when this was introduced and wny... the history of this change might be interesting.
Was this already existing like this in 4.x?
Comment #11
grevil commentedMR!104 seems fine, I will check the points you gave.
But we should check the original issue, this was added in.
Yes.
Comment #12
grevil commentedIt gets escaped based on the field provided. For example, if we use the body WYSIWYG field, and use "FULL HTML", nothing is escaped and we can "inject" scripts in the caption. If we use "Restricted HTMl" it gets escaped. Normal field values do get escaped, so I get we need additional escaping here.
Comment #13
grevil commentedDon't quite understand a few points, but please review! Should be all set now!
Comment #15
anybody@Grevil: I left comments, please see.
Which?
Comment #16
anybodyComment #17
grevil commentedThis.
Comment #18
anybodyI meant the field display select options. Currently they show the field machine name. If simple, we should improve it like described Prefix + HR + MR names (see above)
Separate issue now: #3393024: Make the default Caption source 'title' (not 'alt')
Fixed by MR!104
@Grevil: Clearer now?
Comment #19
grevil commentedyes
Comment #20
grevil commentedOk, please review once again @Anybody!
Comment #21
anybodyCommented finally. Afterwards RTBC + Merge, as these are only textual changes.
Comment #22
grevil commentedAlright, tiny code adjustment, good thing tests exist! 😅
Final review through the adjusted test :)
Comment #23
grevil commentedI am going insane, with these freaking field formatter third party settings!!!!
Comment #24
grevil commentedShould be fixed now, please review!
Comment #25
anybodyPHPCS is complaining (and eslint but I think that's old)
And one unresolved comment.
Comment #26
grevil commentedThe phpcs issue was also related to another issue, but fixed anyway!
Comment #27
grevil commentedAlright, all green now! I accidentally skipped the pipeline and executed it manually afterwards. Unfortunately the UI shows it still as "skipped", see here for the pipeline output: https://git.drupalcode.org/issue/photoswipe-3392976/-/pipelines/29389.
Comment #28
grevil commentedComment #29
anybodyRTBC! :)
Comment #30
anybody