Last active
April 9, 2018 16:52
-
-
Save azinasili/71402a2b1008fa8c48a5 to your computer and use it in GitHub Desktop.
Easily add images + path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// File path short cut for media | |
/// @param {string} $img-name - Name of media to append to path | |
/// @return {url} url to display media | |
/// @warn Warning when $img-name has no extention | |
/// @example scss | |
/// .foo { | |
/// background: image-url('kitten.jpg') no-repeat 0 0; | |
/// } | |
/// @example css | |
/// .foo { | |
/// background: url('path/to/kitten.jpg') no-repeat 0 0; | |
/// } | |
@function img-path($img-name) { | |
$img-path: 'path/to'; | |
@if not str-index($img-name , '.') { | |
@warn '`#{$img-name}` needs a file extension like .jpg or .png'; | |
@return false; | |
} @else { | |
@return url('#{$img-path}/#{$img-name}'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment