Code fails only if not logged in
As per the error message, no such index 'entity' exists in the array $value-&gt;field_field_screenshot[0]['rendered'] Do a dpm($value-&gt;field_field_screenshot[0]['rendered']) when both logged in and logged out and you will see the difference.

Is field_screenshot associated with a user account or profile? In which case, the anonymous user object has no such field, so you're trying to assign to $collect_field something that doesn't exist. You should assert whether the user is logged in or not before doing the assignment.