Can I send a function as an argument to the background-image URL parameter in jQuery?
Is it possible to achieve something similar to this example...
jQuery('<span>').css('background-image', 'url(' + check_file_type(value.Name) + ')');
The function provides the proper format for the URL address, but perhaps I am not invoking it correctly.
function get_extension(filename) {
return filename.split('.').pop().toLowerCase();
}
function check_file_type(file) {
switch(get_extension(file)) {
//if .jpg/.gif/.png do something
case 'jpg': case 'gif': case 'png':
return '{!URLFOR($Resource.images, 'images/doctype_image.png')}';
break;
//if .zip/.rar do something else
case 'zip': case 'rar':
return '{!URLFOR($Resource.images, 'images/doctype_zip.png')}';
break;
//if .pdf do something else
case 'pdf': case 'pptx':
return '{!URLFOR($Resource.images, 'images/doctype_pdf.png')}';
break;
}
}