本文整理汇总了PHP中wr2x_getoption函数的典型用法代码示例。如果您正苦于以下问题:PHP wr2x_getoption函数的具体用法?PHP wr2x_getoption怎么用?PHP wr2x_getoption使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wr2x_getoption函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: wr2x_vt_resize
function wr2x_vt_resize($file_path, $width, $height, $newfile)
{
$orig_size = getimagesize($file_path);
$image_src[0] = $file_path;
$image_src[1] = $orig_size[0];
$image_src[2] = $orig_size[1];
$file_info = pathinfo($file_path);
$extension = '.' . $file_info['extension'];
$no_ext_path = $file_info['dirname'] . '/' . $file_info['filename'];
$cropped_img_path = $no_ext_path . '-' . $width . 'x' . $height . "-tmp" . $extension;
$image = wp_get_image_editor($file_path);
$image->resize($width, $height, true);
$quality = wr2x_getoption("image_quality", "wr2x_advanced", "80");
if (is_numeric($quality)) {
$image->set_quality(intval($quality));
}
$image->save($cropped_img_path);
if (rename($cropped_img_path, $newfile)) {
$cropped_img_path = $newfile;
}
$new_img_size = getimagesize($cropped_img_path);
$new_img = str_replace(basename($image_src[0]), basename($cropped_img_path), $image_src[0]);
$vt_image = array('url' => $new_img, 'width' => $new_img_size[0], 'height' => $new_img_size[1]);
return $vt_image;
}
开发者ID:roycocup,项目名称:enclothed,代码行数:25,代码来源:wr2x_vt_resize.php
示例2: wr2x_wp_calculate_image_srcset
/**
*
* SUPPORT FOR WP 4.4
*
*/
function wr2x_wp_calculate_image_srcset($srcset, $size)
{
if (wr2x_getoption("disable_responsive", "wr2x_basics", false)) {
return null;
}
$method = wr2x_getoption("method", "wr2x_advanced", 'Picturefill');
if ($method == "none") {
return $srcset;
}
$count = 0;
$total = 0;
$retinized_srcset = $srcset;
if (empty($srcset)) {
return $srcset;
}
foreach ($srcset as $s => $cfg) {
$total++;
$retina = wr2x_get_retina_from_url($cfg['url']);
if (!empty($retina)) {
$count++;
$retinized_srcset[(int) $s * 2] = array('url' => $retina, 'descriptor' => 'w', 'value' => (int) $s * 2);
}
}
wr2x_log("WP's srcset: " . $count . " retina files added out of " . $total . " image sizes");
return $retinized_srcset;
}
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:31,代码来源:wr2x_responsive.php
示例3: wr2x_generate_rewrite_rules
function wr2x_generate_rewrite_rules($wp_rewrite, $flush = false)
{
global $wp_rewrite;
$method = wr2x_getoption("method", "wr2x_advanced", "retina.js");
if ($method == "Retina-Images") {
// MODIFICATION: docwhat
// get_home_url() -> trailingslashit(site_url())
// REFERENCE: http://wordpress.org/support/topic/plugin-wp-retina-2x-htaccess-generated-with-incorrect-rewriterule
// MODIFICATION BY h4ir9
// .*\.(jpg|jpeg|gif|png|bmp) -> (.+.(?:jpe?g|gif|png))
// REFERENCE: http://wordpress.org/support/topic/great-but-needs-a-little-update
$handlerurl = str_replace(trailingslashit(site_url()), '', plugins_url('wr2x_image.php', __FILE__));
add_rewrite_rule('(.+.(?:jpe?g|gif|png))', $handlerurl, 'top');
}
if ($flush == true) {
$wp_rewrite->flush_rules();
}
}
开发者ID:roycocup,项目名称:enclothed,代码行数:18,代码来源:wr2x_settings.php
示例4: wr2x_vt_resize
function wr2x_vt_resize($file_path, $width, $height, $crop, $newfile, $customCrop = false)
{
$crop_params = $crop == '1' ? true : $crop;
$orig_size = getimagesize($file_path);
$image_src[0] = $file_path;
$image_src[1] = $orig_size[0];
$image_src[2] = $orig_size[1];
$file_info = pathinfo($file_path);
$newfile_info = pathinfo($newfile);
$extension = '.' . $newfile_info['extension'];
$no_ext_path = $file_info['dirname'] . '/' . $file_info['filename'];
$cropped_img_path = $no_ext_path . '-' . $width . 'x' . $height . "-tmp" . $extension;
$image = wp_get_image_editor($file_path);
if (is_wp_error($image)) {
wr2x_log("Resize failure: " . $image->get_error_message());
error_log("Resize failure: " . $image->get_error_message());
return null;
}
// Resize or use Custom Crop
if (!$customCrop) {
$image->resize($width, $height, $crop_params);
} else {
$image->crop($customCrop['x'] * $customCrop['scale'], $customCrop['y'] * $customCrop['scale'], $customCrop['w'] * $customCrop['scale'], $customCrop['h'] * $customCrop['scale'], $width, $height, false);
}
$quality = wr2x_getoption("image_quality", "wr2x_advanced", "80");
if (is_numeric($quality)) {
$image->set_quality(intval($quality));
}
$saved = $image->save($cropped_img_path);
if (rename($saved['path'], $newfile)) {
$cropped_img_path = $newfile;
} else {
trigger_error("Retina: Could not move " . $saved['path'] . " to " . $newfile . ".", E_WARNING);
error_log("Retina: Could not move " . $saved['path'] . " to " . $newfile . ".");
return null;
}
$new_img_size = getimagesize($cropped_img_path);
$new_img = str_replace(basename($image_src[0]), basename($cropped_img_path), $image_src[0]);
$vt_image = array('url' => $new_img, 'width' => $new_img_size[0], 'height' => $new_img_size[1]);
return $vt_image;
}
开发者ID:silverbux,项目名称:smartmag-magazine-wordpress,代码行数:41,代码来源:wr2x_vt_resize.php
示例5: wr2x_wp_enqueue_scripts
/**
*
* LOAD SCRIPTS IF REQUIRED
*
*/
function wr2x_wp_enqueue_scripts()
{
global $wr2x_version, $wr2x_retinajs, $wr2x_retina_image, $wr2x_picturefill, $wr2x_lazysizes;
$method = wr2x_getoption("method", "wr2x_advanced", 'Picturefill');
if (is_admin() && !wr2x_getoption("retina_admin", "wr2x_advanced", false)) {
return;
}
// Picturefill
if ($method == "Picturefill") {
if (wr2x_is_debug()) {
wp_enqueue_script('wr2x-debug', plugins_url('/js/debug.js', __FILE__), array(), $wr2x_version, false);
}
// Picturefill
if (!wr2x_getoption("picturefill_noscript", "wr2x_advanced", false)) {
wp_enqueue_script('picturefill', plugins_url('/js/picturefill.min.js', __FILE__), array(), $wr2x_picturefill, false);
}
// Lazysizes
if (wr2x_getoption("picturefill_lazysizes", "wr2x_advanced", false) && wr2x_is_pro()) {
wp_enqueue_script('lazysizes', plugins_url('/js/lazysizes.min.js', __FILE__), array(), $wr2x_lazysizes, false);
}
return;
}
// Debug + HTML Rewrite = No JS!
if (wr2x_is_debug() && $method == "HTML Rewrite") {
return;
}
// Debug mode, we force the devicePixelRatio to be Retina
if (wr2x_is_debug()) {
wp_enqueue_script('wr2x-debug', plugins_url('/js/debug.js', __FILE__), array(), $wr2x_version, false);
} else {
if (wr2x_getoption("ignore_mobile", "wr2x_advanced", false)) {
$mobileDetect = new Mobile_Detect();
if ($mobileDetect->isMobile()) {
return;
}
}
}
// Retina-Images and HTML Rewrite both need the devicePixelRatio cookie on the server-side
if ($method == "Retina-Images" || $method == "HTML Rewrite") {
wp_enqueue_script('retina-images', plugins_url('/js/retina-cookie.js', __FILE__), array(), $wr2x_retina_image, false);
}
// Retina.js only needs itself
if ($method == "retina.js") {
wp_enqueue_script('retinajs', plugins_url('/js/retina.min.js', __FILE__), array(), $wr2x_retinajs, true);
}
}
开发者ID:radscheit,项目名称:unicorn,代码行数:51,代码来源:wp-retina-2x.php
示例6: wpr2x_wp_retina_2x
//.........这里部分代码省略.........
}
?>
href='?page=wp-retina-2x&s=<?php
echo $s;
?>
&view=issues'><?php
_e("Issues", 'wp-retina-2x');
?>
</a><span class="count">(<?php
echo $issues_count;
?>
)</span></li> |
<li class="all"><a <?php
if ($view == 'ignored') {
echo "class='current'";
}
?>
href='?page=wp-retina-2x&s=<?php
echo $s;
?>
&view=ignored'><?php
_e("Ignored", 'wp-retina-2x');
?>
</a><span class="count">(<?php
echo count($ignored);
?>
)</span></li>
</ul>
<table class='wp-list-table widefat fixed media'>
<thead><tr>
<?php
echo "<th style='width: 64px;''></th>";
echo "<th style='font-size: 11px; font-family: Verdana;'>" . __("Title", 'wp-retina-2x') . "</th>";
$ignore_cols = wr2x_getoption("ignore_sizes", "wr2x_basics", array());
foreach ($sizes as $name => $attr) {
if (!in_array($name, $ignore_cols)) {
echo "<th style='width: 80px; font-size: 11px; font-family: Verdana;' class='manage-column'>" . $name . "</th>";
}
}
echo "<th style='font-size: 11px; font-family: Verdana; width: 88px;'>" . __("Actions", 'wp-retina-2x') . "</th>";
echo "<th style='font-size: 11px; font-family: Verdana; width: 70px;'></th>";
?>
</tr></thead>
<tbody>
<?php
foreach ($results as $index => $attr) {
$meta = wp_get_attachment_metadata($attr['post']->ID);
// Let's clean the issues status
if ($view != 'issues') {
wr2x_update_issue_status($attr['post']->ID, $issues, $attr['info']);
}
if (isset($meta) && isset($meta['width'])) {
$original_width = $meta['width'];
$original_height = $meta['height'];
}
$attachmentsrc = wp_get_attachment_image_src($attr['post']->ID, 'thumbnail');
echo "<tr class='wr2x-file-row' postId='" . $attr['post']->ID . "'>";
echo "<td class='wr2x-image'><img style='max-width: 42px; max-height: 42px;' src='" . $attachmentsrc[0] . "' /></td>";
echo "<td class='wr2x-title'><a style='position: relative; top: -2px;' href='media.php?attachment_id=" . $attr['post']->ID . "&action=edit'>" . $attr['post']->post_title . '<br />' . "<span style='font-size: 9px; line-height: 10px; display: block;'>" . $original_width . "×" . $original_height . "</span>";
"</a></td>";
foreach ($sizes as $aindex => $aval) {
if (in_array($aindex, $ignore_cols)) {
continue;
}
$aval = isset($attr['info']) && isset($attr['info'][$aindex]) ? $attr['info'][$aindex] : null;
echo "<td id='wr2x_" . $aindex . "_" . $attr['post']->ID . "'>";
开发者ID:srinivasulurao,项目名称:transcharity,代码行数:67,代码来源:wr2x_retina-dashboard.php
示例7: wpr2x_wp_retina_2x
//.........这里部分代码省略.........
</form>
<!-- REMOVE BUTTON ALL -->
<a id='wr2x_remove_button_all' onclick='wr2x_delete_all()' class='button button-red' style='float: right;'><img style='position: relative; top: 3px; left: -2px; margin-right: 3px; width: 16px; height: 16px;' src='<?php
echo plugin_dir_url(__FILE__);
?>
img/burn.png' /><?php
_e("Bulk Delete", 'wp-retina-2x');
?>
</a>
<!-- GENERATE ALL -->
<a id='wr2x_generate_button_all' onclick='wr2x_generate_all()' class='button-primary' style='float: right; margin-right: 5px;'><img style='position: relative; top: 3px; left: -2px; margin-right: 3px; width: 16px; height: 16px;' src='<?php
echo plugin_dir_url(__FILE__);
?>
img/photo-album--plus.png' /><?php
_e("Bulk Generate", 'wp-retina-2x');
?>
</a>
<!-- PROGRESS -->
<span style='margin-left: 12px; font-size: 13px; top: 5px; position: relative; color: #24547C; font-weight: bold;' id='wr2x_progression'></span>
</div>
<?php
if (isset($_GET['clearlogs']) ? $_GET['clearlogs'] : 0) {
echo "<div class='updated' style='margin-top: 20px;'><p>";
_e("The logs have been cleared.", 'wp-retina-2x');
echo "</p></div>";
}
$active_sizes = wr2x_get_active_image_sizes();
$full_size_needed = wr2x_getoption("full_size", "wr2x_basics", false);
$max_width = 0;
$max_height = 0;
foreach ($active_sizes as $name => $active_size) {
if ($active_size['height'] != 9999 && $active_size['height'] > $max_height) {
$max_height = $active_size['height'];
}
if ($active_size['width'] != 9999 && $active_size['width'] > $max_width) {
$max_width = $active_size['width'];
}
}
$max_width = $max_width * 2;
$max_height = $max_height * 2;
$upload_max_size = ini_get('upload_max_filesize');
?>
<p>
<?php
printf(__('The full-size images should have a resolution of <b>%d×%d</b> at least for the plugin to be able generate the <b>%d retina images</b> required by your website.', 'wp-retina-2x'), $max_width, $max_height, count($active_sizes));
?>
<?php
if ($full_size_needed) {
printf(__("You <b>also need</b> to upload a retina image for the Full-Size image (might be <b>%d×%d</b>).", 'wp-retina-2x'), $max_width * 2, $max_height * 2);
}
?>
<?php
_e("You can upload or replace the images by drag & drop.", 'wp-retina-2x');
?>
<?php
printf(__("Your PHP configuration allows uploads of <b>%dMB</b> maximum.", 'wp-retina-2x'), $upload_max_size);
?>
<?php
开发者ID:shuramita,项目名称:dhsd,代码行数:67,代码来源:wr2x_retina-dashboard.php
示例8: wr2x_wp_ajax_wr2x_list_all
function wr2x_wp_ajax_wr2x_list_all($issuesOnly)
{
$issuesOnly = intval($_POST['issuesOnly']);
if ($issuesOnly == 1) {
$ids = wr2x_get_issues();
echo json_encode(array('success' => true, 'message' => "List of issues only.", 'ids' => $ids, 'total' => count($ids)));
die;
}
$reply = array();
try {
$ids = array();
$total = 0;
global $wpdb;
$postids = $wpdb->get_col("\n\t\t\tSELECT p.ID\n\t\t\tFROM {$wpdb->posts} p\n\t\t\tWHERE post_status = 'inherit'\n\t\t\tAND post_type = 'attachment'\n\t\t\tAND ( post_mime_type = 'image/jpeg' OR\n\t\t\t\tpost_mime_type = 'image/png' OR\n\t\t\t\tpost_mime_type = 'image/gif' )\n\t\t");
$ignore = wr2x_getoption("ignore_sizes", "wr2x_basics", array());
foreach ($postids as $id) {
if (wr2x_is_ignore($id)) {
continue;
}
array_push($ids, $id);
$total++;
}
echo json_encode(array('success' => true, 'message' => "List of everything.", 'ids' => $ids, 'total' => $total));
die;
} catch (Exception $e) {
echo json_encode(array('success' => false, 'message' => $e->getMessage()));
die;
}
}
开发者ID:frankynomad,项目名称:bux-wpcontent,代码行数:29,代码来源:wr2x_ajax.php
示例9: wr2x_wp_enqueue_scripts
/**
*
* LOAD SCRIPTS IF REQUIRED
*
*/
function wr2x_wp_enqueue_scripts()
{
global $wr2x_version, $wr2x_retinajs, $wr2x_retina_image;
$method = wr2x_getoption("method", "wr2x_advanced", 'retina.js');
// Debug + HTML Rewrite = No JS!
if (wr2x_is_debug() && $method == "HTML Rewrite") {
return;
}
// Debug mode, we force the devicePixelRatio to be Retina
if (wr2x_is_debug()) {
wp_enqueue_script('debug', plugins_url('/js/debug.js', __FILE__), array(), $wr2x_version, false);
} else {
if (wr2x_getoption("ignore_mobile", "wr2x_advanced", false)) {
$mobileDetect = new Mobile_Detect();
if ($mobileDetect->isMobile()) {
return;
}
}
}
// Retina-Images and HTML Rewrite both need the devicePixelRatio cookie on the server-side
if ($method == "Retina-Images" || $method == "HTML Rewrite") {
wp_enqueue_script('retina-images', plugins_url('/js/retina-cookie.js', __FILE__), array(), $wr2x_retina_image, false);
}
// Retina.js only needs itself
if ($method == "retina.js") {
wp_enqueue_script('retinajs', plugins_url('/js/retina.js', __FILE__), array(), $wr2x_retinajs, true);
}
}
开发者ID:roycocup,项目名称:enclothed,代码行数:33,代码来源:wp-retina-2x.php
示例10: ewww_image_optimizer_resize_upload
function ewww_image_optimizer_resize_upload($file)
{
// parts adapted from Imsanity (THANKS Jason!)
ewwwio_debug_message('<b>' . __FUNCTION__ . '()</b>');
if (!$file) {
return false;
}
// ewwwio_debug_message( print_r( $_SERVER, true ) );
if (!empty($_REQUEST['post_id']) || !empty($_REQUEST['action']) && $_REQUEST['action'] === 'upload-attachment' || !empty($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'media-new.php')) {
$maxwidth = ewww_image_optimizer_get_option('ewww_image_optimizer_maxmediawidth');
$maxheight = ewww_image_optimizer_get_option('ewww_image_optimizer_maxmediaheight');
ewwwio_debug_message('resizing image from media library or attached to post');
} else {
$maxwidth = ewww_image_optimizer_get_option('ewww_image_optimizer_maxotherwidth');
$maxheight = ewww_image_optimizer_get_option('ewww_image_optimizer_maxotherheight');
ewwwio_debug_message('resizing images from somewhere else');
}
// allow other developers to modify the dimensions to their liking based on whatever parameters they might choose
list($maxwidth, $maxheight) = apply_filters('ewww_image_optimizer_resize_dimensions', array($maxwidth, $maxheight));
//check that options are not == 0
if ($maxwidth == 0 && $maxheight == 0) {
return false;
}
//check file type
$type = ewww_image_optimizer_mimetype($file, 'i');
if (strpos($type, 'image') === FALSE) {
ewwwio_debug_message('not an image, cannot resize');
return false;
}
//check file size (dimensions)
list($oldwidth, $oldheight) = getimagesize($file);
if ($oldwidth <= $maxwidth && $oldheight <= $maxheight) {
ewwwio_debug_message('image too small for resizing');
return false;
}
list($newwidth, $newheight) = wp_constrain_dimensions($oldwidth, $oldheight, $maxwidth, $maxheight);
if (!function_exists('wp_get_image_editor')) {
ewwwio_debug_message('no image editor function');
return false;
}
remove_filter('wp_image_editors', 'ewww_image_optimizer_load_editor', 60);
$editor = wp_get_image_editor($file);
if (is_wp_error($editor)) {
ewwwio_debug_message('could not get image editor');
return false;
}
if (function_exists('exif_read_data') && $type === 'image/jpeg') {
$exif = @exif_read_data($file);
if (is_array($exif) && array_key_exists('Orientation', $exif)) {
$orientation = $exif['Orientation'];
switch ($orientation) {
case 3:
$editor->rotate(180);
break;
case 6:
$editor->rotate(-90);
break;
case 8:
$editor->rotate(90);
break;
}
}
}
$resized_image = $editor->resize($newwidth, $newheight);
if (is_wp_error($resized_image)) {
ewwwio_debug_message('error during resizing');
return false;
}
$new_file = $editor->generate_filename('tmp');
$orig_size = filesize($file);
$saved = $editor->save($new_file);
if (is_wp_error($saved)) {
ewwwio_debug_message('error saving resized image');
}
add_filter('wp_image_editors', 'ewww_image_optimizer_load_editor', 60);
$new_size = ewww_image_optimizer_filesize($new_file);
if ($new_size && $new_size < $orig_size) {
// generate a retina file from the full original if they have WP Retina 2x Pro
if (function_exists('wr2x_is_pro') && wr2x_is_pro()) {
$full_size_needed = wr2x_getoption("full_size", "wr2x_basics", false);
if ($full_size_needed) {
// Is the file related to this size there?
$retina_file = '';
$pathinfo = pathinfo($file);
$retina_file = trailingslashit($pathinfo['dirname']) . $pathinfo['filename'] . wr2x_retina_extension() . $pathinfo['extension'];
if ($retina_file && !file_exists($retina_file) && wr2x_are_dimensions_ok($oldwidth, $oldheight, $newwidth * 2, $newheight * 2)) {
$image = wr2x_vt_resize($file, $newwidth * 2, $newheight * 2, false, $retina_file);
}
}
}
rename($new_file, $file);
// store info on the current image for future reference
global $wpdb;
$already_optimized = ewww_image_optimizer_find_already_optimized($file);
// if the original file has never been optimized, then just update the record that was created with the proper filename (because the resized file has usually been optimized)
if (empty($already_optimized)) {
$tmp_exists = $wpdb->update($wpdb->ewwwio_images, array('path' => $file, 'orig_size' => $orig_size), array('path' => $new_file));
// if the tmp file didn't get optimized (and it shouldn't), then just insert a dummy record to be updated shortly
if (!$tmp_exists) {
$wpdb->insert($wpdb->ewwwio_images, array('path' => $file, 'orig_size' => $orig_size));
//.........这里部分代码省略.........
开发者ID:crazyyy,项目名称:bessarabia,代码行数:101,代码来源:common.php
示例11: __rocket_cdn_on_images_from_wp_retina_x2
function __rocket_cdn_on_images_from_wp_retina_x2($url)
{
if (wr2x_is_pro()) {
$cdn_domain = wr2x_getoption("cdn_domain", "wr2x_advanced", "");
}
if (empty($cdn_domain)) {
return get_rocket_cdn_url($url, array('all', 'images'));
}
return $url;
}
开发者ID:EliasGoldberg,项目名称:troop-sim,代码行数:10,代码来源:plugin-compatibility.php
注:本文中的wr2x_getoption函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论