本文整理汇总了PHP中remove_image_size函数的典型用法代码示例。如果您正苦于以下问题:PHP remove_image_size函数的具体用法?PHP remove_image_size怎么用?PHP remove_image_size使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了remove_image_size函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: adaline_logo_letter_setup
/**
* Remove unneeded Jetpack Logo related functions.
* Hook into after_theme_setup with priority of 11
* to override parent theme functions.
*
* @link https://codex.wordpress.org/Function_Reference/remove_theme_support
*
*/
function adaline_logo_letter_setup()
{
// This will remove the image size used exclusively with Jetpack Site Logo
remove_image_size('adaline-logo');
// This will remove theme support for Jetpack Site Logo
remove_theme_support('site-logo');
}
示例2: test_get_intermediate_sizes_by_name
/**
* @ticket 17626
*/
function test_get_intermediate_sizes_by_name()
{
add_image_size('test-size', 330, 220, true);
$file = DIR_TESTDATA . '/images/waffles.jpg';
$id = $this->_make_attachment($file, 0);
// look for a size by name
$image = image_get_intermediate_size($id, 'test-size');
// cleanup
remove_image_size('test-size');
// test for the expected string because the array will by definition
// return with the correct height and width attributes
$this->assertTrue(strpos($image['file'], '330x220') > 0);
}
示例3: test_get_item_sizes_with_no_url
public function test_get_item_sizes_with_no_url()
{
$attachment_id = $this->factory->attachment->create_object($this->test_file, 0, array('post_mime_type' => 'image/jpeg', 'post_excerpt' => 'A sample caption'), $this->test_file);
add_image_size('rest-api-test', 119, 119, true);
wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $this->test_file));
add_filter('wp_get_attachment_image_src', '__return_false');
$request = new WP_REST_Request('GET', '/wp/v2/media/' . $attachment_id);
$response = $this->server->dispatch($request);
$data = $response->get_data();
remove_filter('wp_get_attachment_image_src', '__return_false');
remove_image_size('rest-api-test');
$this->assertFalse(isset($data['media_details']['sizes']['rest-api-test']['source_url']));
}
示例4: _remove_image_sizes
protected function _remove_image_sizes()
{
remove_image_size('jetpack_soft_defined');
remove_image_size('jetpack_soft_undefined');
remove_image_size('jetpack_soft_undefined_zero');
remove_image_size('jetpack_hard_defined');
remove_image_size('jetpack_hard_undefined');
remove_image_size('jetpack_hard_undefined_zero');
remove_image_size('jetpack_soft_defined_after_upload');
remove_image_size('jetpack_soft_undefined_after_upload');
remove_image_size('jetpack_soft_undefined_zero_after_upload');
remove_image_size('jetpack_hard_defined_after_upload');
remove_image_size('jetpack_hard_undefined_after_upload');
remove_image_size('jetpack_hard_undefined_zero_after_upload');
remove_image_size('jetpack_soft_oversized');
remove_image_size('jetpack_soft_oversized_after_upload');
}
示例5: wr2x_init
function wr2x_init()
{
load_plugin_textdomain('wp-retina-2x', false, dirname(plugin_basename(__FILE__)) . '/languages/');
if (wr2x_getoption('disable_medium_large', 'wr2x_basics', false)) {
remove_image_size('medium_large');
add_filter('image_size_names_choose', 'wr2x_unset_medium_large');
add_filter('intermediate_image_sizes_advanced', 'wr2x_unset_medium_large');
}
if (is_admin()) {
wp_register_style('wr2x-admin-css', plugins_url('/wr2x_admin.css', __FILE__));
wp_enqueue_style('wr2x-admin-css');
if (!wr2x_getoption("retina_admin", "wr2x_advanced", false)) {
return;
}
}
$method = wr2x_getoption("method", "wr2x_advanced", 'Picturefill');
if ($method == "Picturefill") {
add_action('wp_head', 'wr2x_picture_buffer_start');
add_action('wp_footer', 'wr2x_picture_buffer_end');
} else {
if ($method == 'HTML Rewrite') {
$is_retina = false;
if (isset($_COOKIE['devicePixelRatio'])) {
$is_retina = ceil(floatval($_COOKIE['devicePixelRatio'])) > 1;
if (wr2x_getoption("ignore_mobile", "wr2x_advanced", false)) {
$mobileDetect = new Mobile_Detect();
$is_retina = !$mobileDetect->isMobile();
}
}
if ($is_retina || wr2x_is_debug()) {
add_action('wp_head', 'wr2x_buffer_start');
add_action('wp_footer', 'wr2x_buffer_end');
}
}
}
}
示例6: test_remove_image_size
/**
* @ticket 26768
*/
function test_remove_image_size() {
add_image_size( 'test-size', 200, 600 );
$this->assertTrue( has_image_size( 'test-size' ) );
remove_image_size( 'test-size' );
$this->assertFalse( has_image_size( 'test-size' ) );
}
示例7: test_has_image_size
/**
* @ticket 26951
*/
function test_has_image_size()
{
add_image_size('test-size', 200, 600);
$this->assertTrue(has_image_size('test-size'));
// Clean up
remove_image_size('test-size');
}
示例8: test_fallback_intermediate_image_sizes
/**
* @ticket 39231
*/
public function test_fallback_intermediate_image_sizes()
{
if (!wp_image_editor_supports(array('mime_type' => 'application/pdf'))) {
$this->markTestSkipped('Rendering PDFs is not supported on this system.');
}
$orig_file = DIR_TESTDATA . '/images/wordpress-gsoc-flyer.pdf';
$test_file = '/tmp/wordpress-gsoc-flyer.pdf';
copy($orig_file, $test_file);
$attachment_id = $this->factory->attachment->create_object($test_file, 0, array('post_mime_type' => 'application/pdf'));
$this->assertNotEmpty($attachment_id);
add_image_size('test-size', 100, 100);
add_filter('fallback_intermediate_image_sizes', array($this, 'filter_fallback_intermediate_image_sizes'), 10, 2);
$expected = array('file' => 'wordpress-gsoc-flyer-77x100.jpg', 'width' => 77, 'height' => 100, 'mime-type' => 'image/jpeg');
$metadata = wp_generate_attachment_metadata($attachment_id, $test_file);
$this->assertTrue(isset($metadata['sizes']['test-size']), 'The `test-size` was not added to the metadata.');
$this->assertSame($metadata['sizes']['test-size'], $expected);
remove_image_size('test-size');
remove_filter('fallback_intermediate_image_sizes', array($this, 'filter_fallback_intermediate_image_sizes'), 10);
unlink($test_file);
}
示例9: test_get_intermediate_sizes_should_match_size_with_off_by_one_aspect_ratio
/**
* @ticket 17626
* @ticket 34087
*/
public function test_get_intermediate_sizes_should_match_size_with_off_by_one_aspect_ratio()
{
// Original is 600x400. 300x201 is close enough to match.
$width = 300;
$height = 201;
add_image_size('off-by-one', $width, $height, true);
$file = DIR_TESTDATA . '/images/waffles.jpg';
$id = $this->_make_attachment($file, 0);
$original = wp_get_attachment_metadata($id);
$image_h = $height;
$image_w = round($image_h / $original['height'] * $original['width']);
// look for a size by array that exists
// note: staying larger than 300px to miss default medium crop
$image = image_get_intermediate_size($id, array(0, $height));
$this->assertTrue(strpos($image['file'], $width . 'x' . $height) > 0);
// cleanup
remove_image_size('off-by-one');
}
示例10: test_get_intermediate_sizes_by_array_zero_width
/**
* @ticket 17626
*/
function test_get_intermediate_sizes_by_array_zero_width()
{
// Generate random height
$random_h = rand(200, 300);
// Only one dimention match shouldn't return false positive (see: 17626)
add_image_size('test-size', 0, $random_h, false);
add_image_size('false-height', 300, $random_h, true);
$file = DIR_TESTDATA . '/images/waffles.jpg';
$id = $this->_make_attachment($file, 0);
$original = wp_get_attachment_metadata($id);
$image_h = $random_h;
$image_w = round($image_h / $original['height'] * $original['width']);
// look for a size by array that exists
// note: staying larger than 300px to miss default medium crop
$image = image_get_intermediate_size($id, array(0, $random_h));
// test for the expected string because the array will by definition
// return with the correct height and width attributes
$this->assertTrue(strpos($image['file'], $image_w . 'x' . $image_h) > 0);
// cleanup
remove_image_size('test-size');
remove_image_size('false-height');
}
示例11: image_sizes
/**
* Remove some images sizes.
*/
public function image_sizes()
{
remove_image_size('spine-small_size');
remove_image_size('spine-large_size');
remove_image_size('spine-xlarge_size');
}
示例12: remove
public static function remove($size_name = '')
{
remove_image_size($size_name);
}