app/models/project.rb
# Derive an OpenGraph-custom logo path from the provided path, or return the provided path if the OG logo doesn't exist
Derive an OpenGraph-custom logo path from the provided path, or return the provided path if the OG logo doesn't exist
Derive an OpenGraph - custom logo path from the provided path or return the provided path if the OG logo doesn ' t exist
def og_logo
    if logo
      logo_parts = logo.split('.')
      if logo_parts.length > 1
        stem = "#{logo_parts.first(logo_parts.length - 1).join('.')}-og"
      else
        stem = "#{logo}-og"
      end
      ogl = nil
      %w(jpg jpeg png gif).each do |ext|
        proposed_filename = "#{stem}.#{ext}"
        if image_file_exists?(proposed_filename)
          ogl = proposed_filename
          break
        end
      end
      unless ogl
        ogl = logo
      end
      return ogl
    else
      return nil
    end
  end
def og_logo if logo logo_parts = logo . split ( '.' ) if logo_parts . length > 1 stem = "#{logo_parts.first(logo_parts.length - 1).join('.')}-og" else stem = "#{logo}-og" end ogl = nil %w( jpg jpeg png gif ) . each do | ext | proposed_filename = "#{stem}.#{ext}" if image_file_exists? ( proposed_filename ) ogl = proposed_filename break end end unless ogl ogl = logo end return ogl else return nil end end
Derive an OpenGraph-custom logo path from the provided path, or return the provided path if the OG logo doesn't exist
Derive an OpenGraph - custom logo path from the provided path or return the provided path if the OG logo doesn ' t exist
# Insert '-og' before the extension but after the filename stem # No extension: just append '-og' on the end # Check for stem as .jpg, .jpeg, .png and .gif, then give up # Can't find the og_logo - just go with the project logo