PluginProbe ʕ •ᴥ•ʔ
TinyPNG – JPEG, PNG & WebP image compression / trunk
TinyPNG – JPEG, PNG & WebP image compression vtrunk
3.7.0 3.6.14 trunk 1.0.0 1.1.0 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.4.0 1.5.0 1.6.0 1.7.0 1.7.1 1.7.2 2.0.0 2.0.1 2.0.2 2.1.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 3.0.0 3.0.1 3.1.0 3.2.0 3.2.1 3.3 3.4 3.4.1 3.4.2 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.5.2 3.6.0 3.6.1 3.6.10 3.6.11 3.6.12 3.6.13 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.6.9
tiny-compress-images / src / class-tiny-conversion.php
tiny-compress-images / src Last commit date
compatibility 1 day ago config 1 day ago css 5 months ago data 3 years ago images 3 years ago js 1 day ago vendor 4 months ago views 1 day ago class-tiny-apache-rewrite.php 1 day ago class-tiny-bulk-optimization.php 1 day ago class-tiny-cli.php 1 day ago class-tiny-compress-client.php 1 day ago class-tiny-compress-fopen.php 1 day ago class-tiny-compress.php 1 day ago class-tiny-conversion.php 2 months ago class-tiny-diagnostics.php 5 months ago class-tiny-exception.php 5 months ago class-tiny-helpers.php 1 day ago class-tiny-image-size.php 1 day ago class-tiny-image.php 1 day ago class-tiny-logger.php 1 day ago class-tiny-migrate.php 1 day ago class-tiny-notices.php 1 day ago class-tiny-php.php 1 day ago class-tiny-picture.php 1 day ago class-tiny-plugin.php 1 day ago class-tiny-settings.php 1 day ago class-tiny-source-base.php 2 months ago class-tiny-source-image.php 5 months ago class-tiny-source-picture.php 5 months ago class-tiny-wp-base.php 1 day ago
class-tiny-conversion.php
89 lines
1 <?php
2 /*
3 * Tiny Compress Images - WordPress plugin.
4 * Copyright (C) 2015-2018 Tinify B.V.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc., 51
18 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 /**
22 * class managing conversion delivery method
23 */
24 class Tiny_Conversion extends Tiny_WP_Base {
25
26 /**
27 * @var Tiny_Settings plug-in settings
28 */
29 private $settings;
30
31 /**
32 * @param Tiny_Settings $settings
33 */
34 public function __construct( $settings ) {
35 parent::__construct();
36 $this->settings = $settings;
37 }
38
39 /**
40 * will check if conversion is enabled,
41 * if true:
42 * - will enable the delivery method
43 * - will add hook to toggle rules
44 *
45 * hooked into `init`
46 */
47 public function init() {
48 if ( ! $this->settings->get_conversion_enabled() ) {
49 return;
50 }
51
52 add_action(
53 'update_option_tinypng_convert_format',
54 'Tiny_Apache_Rewrite::toggle_rules',
55 20,
56 3
57 );
58
59 $delivery_method = $this->settings->get_conversion_delivery_method();
60
61 $this->init_image_delivery( $delivery_method );
62 }
63
64 /**
65 * Initializes the method of delivery for optimised images
66 *
67 * @param string $delivery_method 'picture' or 'htaccess'
68 * @return void
69 */
70 private function init_image_delivery( $delivery_method ) {
71 global $is_apache;
72 /**
73 * Controls wether the page should replace <img> with <picture> elements
74 * converted sources.
75 *
76 * @since 3.7.0
77 */
78 if ( 'htaccess' === $delivery_method && $is_apache ) {
79 new Tiny_Apache_Rewrite();
80 return;
81 }
82
83 if ( apply_filters( 'tiny_replace_with_picture', 'picture' === $delivery_method ) ) {
84 new Tiny_Picture( $this->settings, ABSPATH, array( get_site_url() ) );
85 return;
86 }
87 }
88 }
89