2

I am trying to load user profile pictures (the Craft ones), but they don't load. The getPhotoUrl() seems to point to the wrong folder(?).

The profile images seem to be stored in the userprofiles folder by default

{% set users = craft.users %}

{% for user in users %}
    <div class="searchresults"><a href="/profile/{{ user }}">{{ user }}</a>

    {% if user.getPhotoUrl %}
        <img src="{{ user.getPhotoUrl(64) }}" class="profile_search_picture" alt="{{ entry.user.getFullName }}"/>
    {% else %}
        <img src="/img/fallback.png" class="profile_search_picture" alt="{{ entry.user.getFullName }}"/> 
    {% endif %}

</div>
{% endfor %}

2017/04/24 11:24:10 [error] [application] Tried to read the folder contents of /Applications/MAMP/htdocs/craft/storage/runtime/assets/sources/, but could not. 2017/04/24 11:24:10 [error] [application] Tried to read the folder contents of /Applications/MAMP/htdocs/craft/storage/runtime/assets/tempuploads/field_3/, but could not. 2017/04/24 11:24:10 [error] [application] Tried to read the folder contents of /Applications/MAMP/htdocs/craft/storage/runtime/assets/tempuploads/field_4/, but could not. 2017/04/24 11:24:10 [error] [application] Tried to read the folder contents of /Applications/MAMP/htdocs/craft/storage/runtime/assets/tempuploads/user_1/field_3/, but could not. 2017/04/24 11:24:10 [error] [application] Tried to read the folder contents of /Applications/MAMP/htdocs/craft/storage/runtime/assets/tempuploads/user_1/field_4/, but could not. 2017/04/24 11:24:10 [error] [application] Tried to read the folder contents of /Applications/MAMP/htdocs/craft/storage/runtime/temp/uploads/userphotos/harry/, but could not. 2017/04/24 11:24:10 [error] [application] Tried to read the folder contents of /Applications/MAMP/htdocs/craft/storage/runtime/temp/uploads/userphotos/remco/, but could not.


the console gives this error

GET http://localhost/cpresources/userphotos/remco/64/17492405_10212330524487585_7776812525773615973_o.jpg?x=UoEZXg1dH net::ERR_CONNECTION_REFUSED

2 Answers 2

1

I don't think the /Applications/MAMP/htdocs/craft/storage/runtime/assets/sources/ log entries are related to the request when getResourceUrl() is called. Of if they are, they are elsewhere in the request and not as a direct result of calling getResourceUrl()`.

The error in the console seems like the one to investigate. Based on net::ERR_CONNECTION_REFUSED, I'd check to make sure that craft/storage is recursively writable by PHP as a starting point.

1
  • I've checked the permissions and all seems fine here. Even used chmod -R 777 /Applications/MAMP/htdocs/craft/storage to confirm.
    – Remco
    Commented Apr 25, 2017 at 10:48
1

@cole sorted it! I am hosting craft locally and my localhost used the port number as part of it's URL. I switched the ports to 80/81/3306 which took the 8888 port out of the url and also loaded all images.

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.