Closed (fixed)
Project:
Focal Point
Version:
8.x-1.x-dev
Component:
Image Presets
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
13 Nov 2015 at 22:02 UTC
Updated:
24 Aug 2016 at 01:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
VinayLondhe commentedComment #3
VinayLondhe commentedComment #4
VinayLondhe commentedComment #5
bleen commentedprob should be "edit content" or at least "access admin pages". I don't remember the real perm names but we should restrict public access.
missing docblock
- Missing docblock
- camelCase method name
- this needs to be replaced with a method that dynamically checks the effects defined in src/FocalPointEffectBase.php rather than hard coding here.
you removed the initial "\" .... was that intentional?
nit: white space
AHHHHHHHHH!!!! ... Need to find a better way ;) Using $_SERVER['HTTP_REFERER'] is bad
Comment #6
jfrederick commentedThere was an improvement to this patch in #2615332: Changing the focal point indicator does not change the focal point image in the Image Preview, so I am moving that improved patch over here to keep the related work in one place. It incorporates all the work from #4 above, and improves upon that.
Comment #7
jfrederick commentedA slight improvement to the above patch.
FocalPointImageWidget::value() is called early in form processing, and it calls getFocalPoint(). getFocalPoint() might set $this->focalPoint to an empty string.
Later in form processing, FocalPointImageWidget::process() checks if $this->focalPoint is null, but we also need to check for an empty string to account for the work above in FocalPointImageWidget::value().
This also helps out if $this->focal_point was an empty string at the beginning of FocalPointImageWidget::value(), in which case the code in that method does not run, and the value remains an empty string.
Comment #8
bleen commentedThis patch goes in a slightly different direction. It creates the image preview by adding a query parameter to the image style URL. There is still work to do:
Comment #9
ericduran commentedif you move this to $this->getRequest()
then in your unitTest you can easily replace the getRequest with any fake value to test the test.
In the real class you can have return \Drupal::request()->query->get(...)
Comment #10
ericduran commentedIf you want to be real fancy move `\Drupal::request()` to be DI in the constructor.
Comment #11
bleen commentedThis patch fixes the existing unit tests
I went with a test class...
Comment #12
bleen commentedThis patch styles the image preview link more betterer ...
Still todo:
Comment #13
bleen commentedComment #14
bleen commentedComment #15
bleen commentedThis patch adds the original image to the preview page and styles it to be *much* more usable...
Comment #16
bleen commentedA few white space fixes and implemented the string translation trait instead of using the t() function
Comment #17
bleen commentedfixing/adding some unit tests
Comment #18
bleen commentedOk ... I think this is good to go. The only changes in this patch were to a couple of comments.
Anyone want to review?
Comment #19
bleen commentedThis throws an exception if the fid passed into the URL on the preview page is not an image file
Comment #20
bleen commentedI managed to break the preview link ... this fixes it
Comment #21
bleen commentedChasing HEAD
Comment #22
bleen commentedAccording to #2758495: Remove @file tag docblock there are some docblocks that should not be added ... adjusting this appropriately
Comment #23
bleen commentedMaking the preview link configurable. To display, or not to display; that is the question...
Comment #24
slashrsm commentedLooks great. It seems to me that the preview page is something we could potentially show in a dialog. Maybe a follow-up?
Few things that I noticed while reading through the patch:
I don't see any reason for this configuration not to live in focal_point.settings.yml
I am not sure of this is the best permission to use. Could we check if the current user is the author of the file or has access to edit any of the entities that use this file?
Since the route uses "access content" permission this could allow for DDoS attacks. Another reason to figure out better access control.
Extra newline between comment and the function implementation.
Could we inject this?
Inject?
Comment #25
bleen commentedSome good points in #24.. thanks!!
This fixes the permission issue (and the whitespace nit). I will inject the drupal services shortly.
Modal window is definitely on the table, but as a follow-up.
As for the separate config file, I prefer it separated and there doesn't seem to be a well-defined rule-of-thumb on that one :)
Thanks for the review!!
Comment #26
slashrsm commentedGreat!
Sure. I didn't find a rule like that either. It comes down to personal preference. :)
Comment #27
realityloop commentedComment #28
realityloop commentedOn clean install:
Comment #29
bleen commentedThis patch does the following:
Comment #30
bleen commentedThe patch in #29 also handles permissions better as per #24.3 by adding a custom access function here: \Drupal\focal_point\Controller\FocalPointPreviewController::access. Not sure why it's not in the interdiff, but it goes something like this:
I thin its time to commit this thing ... any final thoughts?
Comment #32
bleen commentedCommitted... Wooooot!!!
Comment #33
bleen commented