Square orientation user avatar generation for CP header #5731
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #5729
This one takes different approach from #5730, here I forcefully generate 1:1 aspect ratio image with existing
ThumbnailController@show
route.However I had to change
ThumbnailController
to allow to override orientation, because before it would read the orientation from the asset, and it would be impossible to forcecp_thumbnail_small_square
image manipulation preset.The only other place where this thumbnail route seems to be used is in
src/Assets/Asset.php
. The orientation path segment is optional and should not break existing usage.One concern I see is that the
avatar()
method onHasAvatar
trait could impact the avatar outputted on Antlers front-end, but from what I can see it does not (I tried outputting avatar from{{ current_user }}
. From my understandingStatamic/Auth/User
is used for CP user only? It would be amusing to receive an URL from CP thumbnail route.I am okay if this PR does not get merged, while this is neater solution than #5730, it is slightly more complex and riskier (maybe it breaks something I am not aware of). But if you think this is good approach, then let me know if this needs additional adjustments, more than happy to address them. Regardless this was a journey for me to deep dive Statamic CMS source code a bit.