Esempio n. 1
0
/**
 * API call.
 * 
 * @param type $img
 * @param type $args
 * @return type
 */
function types_image_resize($img, $args = array())
{
    WPCF_Loader::loadView('image');
    $view = Types_Image_View::getInstance();
    $args = wp_parse_args($args, array('return' => 'url', 'suppress_errors' => !TYPES_DEBUG));
    $resized = $view->resize($img, $args);
    if (!is_wp_error($resized)) {
        switch ($args['return']) {
            case 'object':
                return $resized;
                break;
            case 'path':
                return $resized->path;
                break;
            case 'url':
            default:
                return $resized->url;
                break;
        }
    } else {
        if (!$args['suppress_errors']) {
            return $resized;
        }
    }
    return $img;
}
/**
 * Returns path to attachment relative to upload_dir.
 *
 * @param type $abspath
 * @return string '2014/01/img.jpg'
 */
function wpcf_image_normalize_attachment($abspath)
{
    WPCF_Loader::loadView('image');
    return Types_Image_Utils::getInstance()->normalizeAttachment($abspath);
}