} $used[$element_id] = $saved; // Keep track of used elements per element ID update_post_meta($imageData['id'], 'upfront_used_image_sizes', $used); // *** Flags updated, files clear. Moving on return array('error' => false, 'url' => $url, 'urlOriginal' => $urlOriginal, 'full' => $full_size, 'crop' => $image_editor->get_size()); } function calculate_image_resize_data($custom, $full) { $image_factor = $full['width'] / $full['height']; $custom_factor = $custom['width'] / $custom['height']; $pivot = $image_factor > $custom_factor ? 'height' : 'width'; $factor = $custom[$pivot] / $full[$pivot]; $transformations = array('rotate' => 0); $resize = array('width' => round($full['width'] * $factor), 'height' => round($full['height'] * $factor)); $crop = $custom; $crop['left'] = $resize['width'] > $crop['width'] ? floor(($resize['width'] - $crop['width']) / 2) : 0; $crop['top'] = $resize['height'] > $crop['height'] ? floor(($resize['height'] - $crop['height']) / 2) : 0; $transformations['crop'] = $crop; $transformations['resize'] = $resize; return $transformations; } function save_resizing() { $data = stripslashes_deep($_POST); $layout = Upfront_Layout::from_entity_ids($data['layout']); return $this->_out(new Upfront_JsonResponse_Success($layout->get_element_data('uslider-object-1388746230599-1180'))); } } Upfront_Uimage_Server::serve();
public function update_image_thumbs($meta_id, $post_id, $key, $value) { if ($key != '_inserts_data') { return; } $inserts = maybe_unserialize($value); if (!is_array($inserts)) { return; } foreach ($inserts as $id => $img) { if (isset($img['imageThumb']) && $img['isLocal'] != 'false') { //We got an image $image_path = $this->get_image_path($img['imageThumb']['src']); //If the file doesn't exits, let's create it if (!file_exists($image_path)) { // Get image data $imageData = Upfront_Uimage_Server::calculate_image_resize_data($img['imageThumb'], $img['imageFull']); // Add the full size image path $imageData['image_path'] = $this->get_image_path($img['imageFull']['src']); $imageData['skip_random_filename'] = true; Upfront_Uimage_Server::resize_image($imageData); } } } }