PluginProbe
WPSSO Core – Complete Schema Markup and Meta Tags / 22.7.0
WPSSO Core – Complete Schema Markup and Meta Tags v22.7.0
22.7.0 22.6.1 22.6.0 22.5.3 22.5.2 22.5.1 22.4.0 22.3.0 22.2.1 22.2.0 22.1.3 22.1.2 22.1.1 22.1.0 22.0.0 21.13.3 21.13.2 trunk 21.13.1
wpsso / lib / integ / media / wp-retina-2x.php

wp-retina-2x.php in WPSSO Core – Complete Schema Markup and Meta Tags 22.7.0, at lib/integ/media/wp-retina-2x.php

78 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * License: GPLv3
4 * License URI: https://www.gnu.org/licenses/gpl.txt
5 * Copyright 2022-2026 Jean-Sebastien Morisset (https://wpsso.com/)
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9
10 die( 'These aren\'t the droids you\'re looking for.' );
11 }
12
13 if ( ! class_exists( 'WpssoIntegMediaWpRetina2x' ) ) {
14
15 class WpssoIntegMediaWpRetina2x {
16
17 private $p; // Wpsso class object.
18
19 public function __construct( &$plugin ) {
20
21 $this->p =& $plugin;
22
23 if ( $this->p->debug->enabled ) {
24
25 $this->p->debug->mark();
26 }
27
28 /*
29 * Filter for the get_option() and update_option() functions.
30 */
31 add_filter( 'option_wr2x_retina_sizes', array( $this, 'update_wr2x_retina_sizes' ), 1000, 1 );
32 add_filter( 'pre_update_option_wr2x_retina_sizes', array( $this, 'update_wr2x_retina_sizes' ), 1000, 1 );
33 add_filter( 'wr2x_custom_crop', array( $this, 'filter_set_image_src_args' ), -1000, 3 );
34
35 add_action( 'wr2x_generate_retina', array( $this, 'action_reset_image_src_args' ), -1000, 1 );
36 }
37
38 /*
39 * Filter for the get_option() and update_option() functions.
40 *
41 * Prevent Perfect Images + Retina (aka WP Retina 2x) from creating 2x images for WPSSO image sizes.
42 */
43 public function update_wr2x_retina_sizes( $mixed ) {
44
45 if ( is_array( $mixed ) ) {
46
47 foreach ( $mixed as $num => $size_name ) {
48
49 if ( 0 === strpos( $size_name, 'wpsso-' ) ) {
50
51 unset( $mixed[ $num ] );
52 }
53 }
54 }
55
56 return $mixed;
57 }
58
59 /*
60 * Save arguments for the 'image_make_intermediate_size' and 'image_resize_dimensions' filters.
61 */
62 public function filter_set_image_src_args( $custom_crop, $pid, $size_name ) {
63
64 WpssoMedia::set_image_src_args( $args = array(
65 'pid' => $pid,
66 'size_name' => $size_name,
67 ) );
68
69 return $custom_crop;
70 }
71
72 public function action_reset_image_src_args( $pid ) {
73
74 WpssoMedia::reset_image_src_args();
75 }
76 }
77 }
78