function getImgSrc($img, $path, $thumb = FALSE)
{
    $error = FALSE;
    if (isset($img) && strlen($img) > 0) {
        if (file_exists($path . trim($img))) {
            if ($thumb) {
                $img = getThumbName($img);
            }
            $imgSrc = $path . trim($img);
        } else {
            $error = TRUE;
        }
    } else {
        $error = TRUE;
    }
    if ($error) {
        if ($thumb) {
            $imgSrc = base_url() . 'data/images/sinImagen_thumb.jpg';
        } else {
            $imgSrc = base_url() . 'data/images/sinImagen.jpg';
        }
    }
    return $imgSrc;
}
/**
 * Creates file data object
 *
 * @param  string   $fileName
 * @param  array    $content
 * @return stdClass
 */
function fileFactory($fileName, $content)
{
    $fullPath = DIRNAME . $fileName;
    $file = new stdClass();
    $file->name = $fileName;
    preg_match('/\\.(\\w+)$/', $fileName, $matches);
    $file->extension = isset($matches[1]) ? $matches[1] : false;
    $file->size = filesize($fullPath);
    $file->date = filemtime($fullPath);
    $file->thumbnail = "?thumb={$fileName}";
    if (in_array(strtolower($file->extension), array('jpg', 'jpeg', 'jpe', 'png', 'gif', 'bmp')) && ($params = @getimagesize($fullPath))) {
        $file->isDimensional = true;
        $file->width = $params[0];
        $file->height = $params[1];
        $userThumbPath = DIRNAME . getThumbName($fileName);
        if (file_exists($userThumbPath)) {
            $file->thumbnail = getThumbName($fileName);
        } elseif (mkdirRecursive(DIRNAME . 'thumbs/')) {
            $thumbPath = DIRNAME . 'thumbs/' . getThumbName($fileName);
            if (file_exists($thumbPath)) {
                $file->thumbnail = 'thumbs/' . getThumbName($fileName);
            }
        }
    } else {
        $file->isDimensional = false;
    }
    $flipped = array_flip($content);
    $key = $flipped[$fileName];
    $file->num = $key + 1;
    $file->previousFile = $key > 0 ? $content[$key - 1] : end($content);
    $file->nextFile = $key < count($content) - 1 ? $content[$key + 1] : reset($content);
    return $file;
}