Module: NeonSakura::ProfileHelper

Defined in:
lib/neon_sakura/profile_helper.rb

Instance Method Summary collapse

Instance Method Details

#gravatar_url(email, size: 80) ⇒ String

Generate Gravatar URL for email address

Note: MD5 is used for Gravatar GUID generation (public identifier, not sensitive data)

Examples:

gravatar_url("user@example.com") # => "https://www.gravatar.com/avatar/..."
gravatar_url("user@example.com", size: 120) # => "https://www.gravatar.com/avatar/...?s=120"

Parameters:

  • email (String)

    Email address to generate Gravatar for

  • size (Integer) (defaults to: 80)

    Image size in pixels (default: 80)

Returns:

  • (String)

    Gravatar URL



16
17
18
19
20
21
22
# File 'lib/neon_sakura/profile_helper.rb', line 16

def gravatar_url(email, size: 80)
  return "" if email.blank?

  require "digest/md5"
  hash = Digest::MD5.hexdigest(email.downcase.strip) # nosemgrep: weak-hashes-md5
  "https://www.gravatar.com/avatar/#{hash}?s=#{size}&d=identicon"
end