function wppa_create_stereo_images($id) { global $wppa_supported_stereo_types; global $wppa_supported_stereo_glasses; // Feature enabled? if (!wppa_switch('enable_stereo')) { return; } // First create new thumbnail wppa_create_thumbnail($id); // Is it a stereo poto? if (!wppa_is_stereo($id)) { // Maybe no longer, delete any anaglyphs wppa_delete_stereo_images($id); return; } // Now the anaglyphs foreach ($wppa_supported_stereo_types as $type) { foreach ($wppa_supported_stereo_glasses as $glas) { wppa_create_stereo_image($id, $type, $glas); } } }
function wppa_get_photo_url($id, $system = 'flat', $x = '0', $y = '0') { global $blog_id; global $wppa_supported_stereo_types; // Does photo exist? $thumb = wppa_cache_thumb($id); if (!$thumb) { return ''; } // Set owner if required wppa_set_owner_to_name($id); // Must re-get cached thumb $thumb = wppa_cache_thumb($id); if (is_feed() && wppa_switch('feed_use_thumb')) { return wppa_get_thumb_url($id, $system); } // If in the cloud... $for_sm = wppa('for_sm'); // Social media do not accept cloud images $is_old = wppa_too_old_for_cloud($id); if (wppa_cdn('front') && !wppa_is_multi($id) && !$is_old && !wppa_is_stereo($id) && !$for_sm) { switch (wppa_cdn('front')) { case 'cloudinary': $x = round($x); $y = round($y); $prefix = is_multisite() && !WPPA_MULTISITE_GLOBAL ? $blog_id . '-' : ''; $t = wppa_switch('enlarge') ? 'fit' : 'limit'; $q = wppa_opt('jpeg_quality'); $sizespec = $x && $y ? 'w_' . $x . ',h_' . $y . ',c_' . $t . ',q_' . $q . '/' : ''; $s = is_ssl() ? 's' : ''; $url = 'http' . $s . '://res.cloudinary.com/' . get_option('wppa_cdn_cloud_name') . '/image/upload/' . $sizespec . $prefix . $thumb['id'] . '.' . $thumb['ext']; return $url; break; } } // Stereo? if (wppa_is_stereo($id)) { // Get type from cookie $st = isset($_COOKIE["stereotype"]) ? $_COOKIE["stereotype"] : 'color'; if (!in_array($st, $wppa_supported_stereo_types)) { $st = '_flat'; } // Get glass from cookie $sg = 'rc'; if (isset($_COOKIE["stereoglass"]) && $_COOKIE["stereoglass"] == 'greenmagenta') { $sg = 'gm'; } // Create the file if not present if (!is_file(wppa_get_stereo_path($id, $st, $sg))) { wppa_create_stereo_image($id, $st, $sg); } // Build the url if ($st == '_flat') { $url = WPPA_UPLOAD_URL . '/stereo/' . $id . '-' . $st . '.jpg' . '?ver=' . get_option('wppa_photo_version', '1'); } else { $url = WPPA_UPLOAD_URL . '/stereo/' . $id . '-' . $st . '-' . $sg . '.jpg' . '?ver=' . get_option('wppa_photo_version', '1'); } // Done return $url; } if (get_option('wppa_file_system') == 'flat') { $system = 'flat'; } // Have been converted, ignore argument if (get_option('wppa_file_system') == 'tree') { $system = 'tree'; } // Have been converted, ignore argument if (!is_numeric($id) || $id < '1') { wppa_dbg_msg('Invalid arg wppa_get_photo_url(' . $id . ')', 'red'); } if ($system == 'tree') { return WPPA_UPLOAD_URL . '/' . wppa_expand_id($thumb['id']) . '.' . $thumb['ext'] . '?ver=' . get_option('wppa_photo_version', '1'); } else { return WPPA_UPLOAD_URL . '/' . $thumb['id'] . '.' . $thumb['ext'] . '?ver=' . get_option('wppa_photo_version', '1'); } }