function dynamic_banner_image_handler in Dynamic Banner 7
Same name and namespace in other branches
- 7.2 dynamic_banner.module \dynamic_banner_image_handler()
- 8.x dynamic_banner.module \dynamic_banner_image_handler()
This function will load imgurl if there is no url for img then it will load the fids into path format
Input 1: The imgurl(s) that we are loading [maybe csv] Input 2: The imgfid(s) that we are loading [maybe csv]
2 calls to dynamic_banner_image_handler()
- dynamic_banner_admin_page in includes/
callbacks.inc - Return a listing of all defined URL aliases. When filter key passed, perform a standard search on the given key, and return the list of matching URL aliases.
- dynamic_banner_block_view in ./
dynamic_banner.module - Implements hook_block_view()
File
- includes/
callbacks.inc, line 850 - Dynamic Banner Admin Pages and various other functions to make them work Most of the code in this file was derived from path module
Code
function dynamic_banner_image_handler($imgurl, $imgfid) {
// we have found the imgurl already in the right format return it
if ($imgurl && $imgurl != '') {
return $imgurl;
}
else {
if (strrpos($imgfid, ',')) {
// split the plain string into an array
$all_fids = explode(",", $imgfid);
// load all files at once
$all_files = file_load_multiple($all_fids);
$retval = "";
// default the return string
// go into all the loaded files
foreach ($all_files as $file) {
// if this is the first time through do not add a comma to the string
if ($retval != "") {
$retval .= ",";
}
// have to translate the public string in the uri back into something browsers understand
$retval .= str_replace('public://', variable_get('file_public_path', '') . '/', $file->uri);
}
return $retval;
}
else {
$file = file_load($imgfid);
// have to translate the public string in the uri back into something browsers understand
$file_path = str_replace('public://', variable_get('file_public_path', '') . '/', $file->uri);
return $file_path;
}
}
}