function knews_resize_img() { global $Knews_plugin; if (!$Knews_plugin->initialized) { $Knews_plugin->init(); } $url_img = $Knews_plugin->post_safe('urlimg'); $width = intval($Knews_plugin->post_safe('width')); $height = intval($Knews_plugin->post_safe('height')); require dirname(__FILE__) . "/includes/resize_img.php"; $jsondata = knews_resize_img_fn($url_img, $width, $height); echo json_encode($jsondata); die; }
function knews_automate_img($id, $x, $y) { if (!has_post_thumbnail($id)) { return false; } $image = wp_get_attachment_image_src(get_post_thumbnail_id($id), 'full'); if (!is_array($image)) { return false; } $blog_url = get_bloginfo('url'); if (substr($blog_url, -1, 1) == '/') { $blog_url = substr($blog_url, 0, strlen($blog_url) - 1); } if (strpos($image[0], $blog_url) === false) { $image[0] = $blog_url . $image[0]; } if ($image[1] <= $x || $image[2] <= $y) { return $image[0]; } $jsondata = knews_resize_img_fn($image[0], $x, $y); if ($jsondata['result'] == 'ok') { return $jsondata['url']; } return false; }