- Assigned to jwilson3
- Status changed to Needs work
almost 2 years ago 4:57pm 19 January 2023 - Issue was unassigned.
- Status changed to Needs review
almost 2 years ago 7:59pm 19 January 2023 - 🇳🇱Netherlands megachriz
I updated the code, made it somewhat cleaner.
There is now a method called
generateInlineSvgData()
. I added "Data" to the end, because its return value is going to be assigned to$element['#svg_data']
if it is not empty.The inline setting check now looks as follows:
// Set properties based on if the SVG is displayed inline or not. if ($this->getSetting('inline') && $svg_data = $this->generateInlineSvgData($uri, $attributes)) { $element['#inline'] = TRUE; $element['#svg_data'] = $svg_data; } else { $element['#inline'] = FALSE; $element['#uri'] = $uri; }
I thought about the following approach too, where
#inline
and#uri
are set earlier and then overridden here:if ($this->getSetting('inline') && $svg_data = $this->generateInlineSvgData($uri, $attributes)) { $element['#inline'] = TRUE; $element['#uri'] = NULL; $element['#svg_data'] = $svg_data; }
I this case there is no
else
code block. I went theelse
block because then#uri
didn't have to be set and unset again. I think an approach like that would make more sense if inline SVG image generation would have taken place in a subclass of SvgImageFieldFormatter. Then there would have been a method that would call the parent method if generating an inline SVG failed. - Status changed to Needs work
almost 2 years ago 7:06pm 9 February 2023 - 🇪🇨Ecuador jwilson3
- A read through of the code changes looks good at first glance, haven't taken a chance to test this manually, and I do want to do that first.
- I'd like to change the verb "generate" in the method signature to "load", which seems more accurate in this context.
- Should we add the new #uri variable to the theme hook info?
- Looks like the MR is no longer mergeable due to some issue queue activity from Martin. Apologies for dropping the ball — I got busy on other things. :(
- Status changed to Needs review
almost 2 years ago 3:28pm 10 February 2023 - 🇳🇱Netherlands megachriz
I rebased the code on the latest 2.2.x. That was quite a thing! I hope I did it correctly. The rebase caused double moduleHandler code that I cleaned up in a new commit.
I'd like to change the verb "generate" in the method signature to "load", which seems more accurate in this context.
Method
generateInlineSvgData()
is renamed toloadInlineSvgData()
.Should we add the new #uri variable to the theme hook info?
"uri" looks like to be already part of that:
/** * Implements hook_theme(). */ function svg_image_field_theme() { return [ 'svg_image_field_formatter' => [ 'variables' => [ 'inline' => FALSE, 'attributes' => NULL, 'uri' => NULL, 'svg_data' => NULL, 'link_url' => NULL, ], ], ]; }
- First commit to issue fork.
-
jwilson3 →
committed f3cebd3c on 2.2.x authored by
MegaChriz →
Issue #3333776 by MegaChriz, jwilson3: Improve stage_file_proxy module...
-
jwilson3 →
committed f3cebd3c on 2.2.x authored by
MegaChriz →
- Status changed to Fixed
almost 2 years ago 7:36pm 20 February 2023 - 🇪🇨Ecuador jwilson3
Tested locally and confirmed the rebase is working correctly. Merged after a little bit of comment improvements.
Thanks @MegaChriz!