Beispiel #1
0
    }
    $image = new RMImage($id);
    if ($image->isNew()) {
        images_send_json(array('message' => __('Specified image does not exists', 'rmcommon'), 'error' => 1, 'token' => $xoopsSecurity->createToken()));
    }
    $author = new RMUser($image->uid);
    $original = pathinfo($image->get_files_path() . '/' . $image->file);
    $dimensions = getimagesize($image->get_files_path() . '/' . $image->file);
    $mimes = (include XOOPS_ROOT_PATH . '/include/mimetypes.inc.php');
    $category_sizes = $cat->getVar('sizes');
    $sizes = array();
    foreach ($category_sizes as $i => $size) {
        if ($size['width'] <= 0) {
            continue;
        }
        $tfile = $image->get_files_path() . '/sizes/' . $original['filename'] . '-' . $size['name'] . '.' . $original['extension'];
        if (!is_file($tfile)) {
            continue;
        }
        $t_dim = getimagesize($tfile);
        $sizes[] = array('width' => $t_dim[0], 'height' => $t_dim[1], 'url' => $image->get_files_url() . '/sizes/' . $original['filename'] . '-' . $size['name'] . '.' . $original['extension'], 'name' => $size['name']);
    }
    $sizes[] = array('width' => $dimensions[0], 'height' => $dimensions[1], 'url' => $image->getOriginal(), 'name' => __('Original', 'rmcommon'));
    $links = array('none' => array('caption' => __('None', 'rmcommon'), 'value' => ''), 'file' => array('caption' => __('File URL', 'rmcommon'), 'value' => XOOPS_UPLOAD_URL . '/' . date('Y', $image->getVar('date')) . '/' . date('m', $image->getVar('date')) . '/' . $image->getVar('file')));
    $links = RMEvents::get()->run_event('rmcommon.image.insert.links', $links, $image, RMHttpRequest::post('url', 'string', ''));
    // Image data
    $data = array('id' => $image->id(), 'title' => $image->title, 'date' => formatTimestamp($image->date, 'l'), 'description' => $image->getVar('desc', 'n'), 'author' => array('uname' => $author->uname, 'uid' => $author->uid, 'avatar' => RMEvents::get()->run_event('rmcommon.get.avatar', $author->email, 40), 'url' => XOOPS_URL . '/userinfo.php?uid=' . $author->email), 'medium' => $image->get_by_size(300), 'url' => $image->get_files_url(), 'original' => array('file' => $original['basename'], 'url' => $image->getOriginal(), 'size' => RMFormat::bytes_format(filesize($image->get_files_path() . '/' . $image->file)), 'width' => $dimensions[0], 'height' => $dimensions[1]), 'mime' => isset($mimes[$original['extension']]) ? $mimes[$original['extension']] : 'application/octet-stream', 'sizes' => $sizes, 'links' => $links);
    $data = RMEvents::get()->run_event('rmcommon.loading.image.details', $data, $image, RMHttpRequest::request('url', 'string', ''));
    $data['token'] = $xoopsSecurity->createToken();
    images_send_json($data);
}
Beispiel #2
0
 /**
  * Get an image from image manager
  * @param $id int Image id
  * @param string Size name from category
  */
 function get_image($id, $size = '')
 {
     if ($id <= 0) {
         return false;
     }
     $img = new RMImage($id);
     if ($img->isNew()) {
         return false;
     }
     $cat = new RMImageCategory($img->getVar('cat'));
     $sizes = $cat->getVar('sizes');
     foreach ($sizes as $s) {
         if ($s['name'] == $size) {
             break;
         }
     }
     $date = explode('-', date('d-m-Y', $img->getVar('date')));
     $file = XOOPS_UPLOAD_URL . '/' . $date[2] . '/' . $date[1] . '/';
     if ($size == '') {
         $file .= $img->getVar('file');
         return $file;
     }
     $file .= 'sizes/' . substr($img->getVar('file'), 0, -4) . '_' . $s['width'] . 'x' . $s['height'] . substr($img->getVar('file'), -4);
     if (!is_file(str_replace(XOOPS_URL, XOOPS_ROOT_PATH, $file))) {
         return $img->getOriginal();
     }
     return $file;
 }