public function CdbController::dynamic_banner_image_handler in Dynamic Banner 8
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]
1 call to CdbController::dynamic_banner_image_handler()
- CdbController::adminListPage in src/
application/ Controller/ CdbController.php - Return a listing of all defined URL aliases.
File
- src/
application/ Controller/ CdbController.php, line 144
Class
Namespace
Drupal\dynamic_banner\application\ControllerCode
public 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::loadMultiple((int) $all_fids);
$retval = "";
// default the return string
// go into all the loaded files
if (isset($all_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
if (isset($file)) {
$fileUrl = $file
->getFileUri();
}
else {
$fileUrl = '';
}
$retval .= str_replace('public://', '/', $fileUrl);
}
}
return $retval;
}
else {
$file = File::load((int) $imgfid);
if (isset($file)) {
$fileUrl = $file
->getFileUri();
}
else {
$fileUrl = '';
}
$file_path = str_replace('public://', '/', $fileUrl);
return $file_path;
}
}
}