Method: Inkcite::View#image_url
- Defined in:
- lib/inkcite/view.rb
#image_url(src) ⇒ Object
Returns the fully-qualified URL to the designated image (e.g. logo.gif) appropriate for the current rendering environment. In development mode, local will have either images/ or images-optim/ prepended on them depending on the status of image optimization.
For non-development builds, fully-qualified URLs may be returned depending on the state of the config.yml and how image-host attributes have been configured.
If a fully-qualified URL is provided, the URL will be returned with the possible addition of the cache-breaker tag.
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'lib/inkcite/view.rb', line 240 def image_url src src_url = '' if Util.is_fully_qualified?(src) src_url << src else # Prepend the image host onto the src if one is specified in the properties. # During local development, images are always expected in an images/ subdirectory. image_host = if development? (@email.optimize_images?? Minifier::IMAGE_CACHE : Email::IMAGES) + '/' else # Use the image host defined in config.yml or, out-of-the-box refer to images/ # in the build directory. self[Email::IMAGE_HOST] || (Email::IMAGES + '/') end src_url << image_host unless image_host.blank? # Add the source of the image. src_url << src end # Cache-bust the image if the caller is expecting it to be there. Util::add_query_param(src_url, Time.now.to_i) if !production? && is_enabled?(Email::CACHE_BUST) # Transpose any embedded tags into actual values. Renderer.render(src_url, self) end |