rubyvideo icon indicating copy to clipboard operation
rubyvideo copied to clipboard

Consider alternative approach for sponsor logo storage

Open DiegoPisa2003 opened this issue 4 months ago • 1 comments

Current Approach

Currently sponsors use a hybrid approach for storing logos:

  • External URL is stored in the logo_url field
  • Fallback to local assets in app/assets/images/sponsors/{slug}/logo.webp
  • If local asset doesn't exist, external URL is used

This approach may be inconsistent with the rest of the application, where external image URLs are never stored.

Current Approach Analysis

Sponsors (Possibly Inconsistent)

def logo_image_path
  # First try local asset, then fallback to logo_url
  if sponsor_image_for("logo.webp")
    sponsor_image_or_default_for("logo.webp")
  elsif logo_url.present?
    logo_url  # ← External URL
  else
    sponsor_image_or_default_for("logo.webp")
  end
end

Events (App Standard)

def avatar_image_path
  event_image_or_default_for("avatar.webp")  # ← Local assets only
end

Proposed Alternative Approach

1. Remove external URL fields

  • Remove logo_url and logo_urls from database
  • Migrate existing data by downloading images
  • Still use logo_url field from YAML files created by the scraper to download the images.

2. Use local assets only

  • Structure: app/assets/images/sponsors/{slug}/logo.webp
  • Keep fallback system to sponsors/default/logo.webp
  • Standardize with the rest of the application

3. Maintain existing functionality

  • Background color: logo_background (white/black/transparent)
  • Border styling: logo_border_class
  • Fallback system: Default image if none exists

Justification

  1. Consistency: Align with app standard where external URLs are never stored
  2. Performance: Load from local instead of external servers
  3. Reliability: No dependency on external sites that might go down
  4. Maintainability: Single approach for all images

Implementation Plan

  1. Create script to download existing logos
  2. Database migration to remove URL fields
  3. Update model to use local assets only
  4. Add a lib that downloads and stores images from scraped data of sponsors (stored in YAML files)

Future Enhancement

We can use the sponsor slugs to tag companies and potentially reach out to them to provide optimized assets themselves. While this won't always happen, it's worth trying as suggested by @brauliomartinezlm. This would ensure we have the highest quality, properly optimized logos directly from the source.

Acknowledgment

I want to say that I saw the PR #885 @marcoroth did, doing an effort on the current logo_url implementation.

I'm simply wondering if we might explore aligning this one aspect more closely with the established patterns used elsewhere in the application, but I fully acknowledge that the current implementation is likely the result of careful consideration and may have valid reasons for its design that I haven't fully grasped yet.

DiegoPisa2003 avatar Aug 08 '25 18:08 DiegoPisa2003

Not sure how applicable it would be here but as an alternative to #881 I think I will add a little ActiveStorage to store the PictureProfile

But for now I would prefer that we store only non critical assets as I plan to use the VPS file system (or a mounted drive)

adrienpoly avatar Aug 09 '25 13:08 adrienpoly