2

Is it possible to do anything with Craft's getPhotoUrl() function to allow images to be processed in a similar way like assets?

For example for our profile photos I'd like them to be returned 45x45 cropped from centre.

Currently if a user were to upload a landscape photo they would see something like 45x25 because the height isn't being maintained.

Thoughts?

1 Answer 1

2

Kind of. They currently aren't technically true "Assets" like in the rest of Craft.

The most you can do is pass in a size to the method getPhotoUrl(45) and you'll get a 45 x 45 square result back. I believe it will crop from the center only.

We have plans for Craft 3 so they'll be treated like 1st class Assets and you'll be able to perform transforms on them like any other Asset.

5
  • Thanks for your help Brad but it doesnt actually crop it as you describe. It does maintain a aspect ratio as i mentioned above as this is the first thing i tried.
    – Andy Lake
    Commented Jul 28, 2015 at 10:31
  • I could be wrong about that... will clarify with @andris.
    – Brad Bell
    Commented Jul 28, 2015 at 16:40
  • I assume this is all in the context of a front-end entry form, no? In the CP, you get an actual cropper modal to use.
    – Brad Bell
    Commented Jul 28, 2015 at 18:37
  • Correct, we're just printing the user photo and we want it to be 64x64 from the centre as you described above.
    – Andy Lake
    Commented Oct 10, 2015 at 10:13
  • Has 2.5 managed to rectify this yet? Can we use transforms on user photos?
    – Andy Lake
    Commented Dec 31, 2015 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.