Enhance Sponsor Avatar and Logo Handling with Fallbacks
Overview
This PR improves the visual consistency and reliability of sponsor displays by implementing fallback systems for both avatars and logos. It addresses cases where external logo URLs become inaccessible and ensures all sponsors have proper visual representation.
What Changed
Enhanced Avatar System
- UI Avatars Integration: Added
generate_avatar_urlmethod that creates dynamic avatars using ui-avatars.com API - Smart Avatar Fallback: Modified
avatar_image_pathto fallback to generated avatars when local images aren't available - Priority System: Local images > logo fallback > generated avatars
Robust Logo URL Handling
- URL Accessibility Validation: Added
logo_url_accessible?method that checks if external logo URLs are actually reachable - Network Resilience: Implements timeout handling (5s open, 10s read) and graceful error handling
- Logo Fallback: When logo URLs are inaccessible, automatically falls back to avatar images instead of broken links
Future enhancement
I was thinking that for the logos_url that are inaccessible, we could mark them someway (maybe with a boolean) as inaccessible in a way that the next time we the app go through the logo_url_accessible? can see that boolean and does not have to do a HTTP request to see if it is accessible.
We would have to take into consideration if we implement that, that maybe the logo_url was momentarily inaccessible and then became accessible again, so periodically the app should try again to access the logo_url
Even if we do not merge this PR, I would like to set the record that we should somehow manage inaccessible logo_url in the backend, not only in the views