1

Trying to display the author photo of the entry (it's there for sure). The Craft 2 way I used entry.author.photoUrl but that is not working so I tried entry.author.photo.url and that does not show anything and no error or warnings.

Is what I am doing correct?

1 Answer 1

6
{{ entry.getAuthor().getPhoto().getUrl() }}

Here is the function. Of course if the author has no photo you'll receive nothing (but an exception). Furthermore this function returns the URL not a HTML tag.

5
  • Thanks Robin! I tried that and still get nothing, even though the profile pic of the author is present. hmmmm
    – Vin
    Commented Apr 25, 2018 at 23:33
  • What does entry.getAuthor.photoId or entry.getAuthor().getPhoto().id output? Commented Apr 25, 2018 at 23:35
  • That returns 279
    – Vin
    Commented Apr 25, 2018 at 23:43
  • Seems like an invalid configuration. You can dump the volume in order to see the url setting. {{ dump(entry.getAuthor().getPhoto().getVolume()) }} there must be an attribute url/ hasUrls if it's empty you have to change the settings in the corresponding volume in your cp Commented Apr 25, 2018 at 23:49
  • Thanks again Robin :) . That was it, the config in assets had @storage/userPhotos. Once I changed File System Path to @webroot/images/blogs/userPhotos and made it accessible to public, it worked!
    – Vin
    Commented Apr 26, 2018 at 0:28

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.