diff --git a/airplane-mode.php b/airplane-mode.php
index ed0cd14..a4bf087 100644
--- a/airplane-mode.php
+++ b/airplane-mode.php
@@ -88,10 +88,13 @@ private function __construct() {
add_action( 'script_loader_src', array( $this, 'block_script_load' ), 100 );
add_action( 'admin_init', array( $this, 'remove_update_crons' ) );
add_action( 'admin_init', array( $this, 'remove_schedule_hook' ) );
-
add_filter( 'embed_oembed_html', array( $this, 'block_oembed_html' ), 1, 4 );
add_filter( 'get_avatar', array( $this, 'replace_gravatar' ), 1, 5 );
- add_filter( 'map_meta_cap', array( $this, 'prevent_auto_updates' ), 10, 2 );
+ add_filter( 'wp_get_attachment_url', array( $this, 'get_local_image_url' ), 10, 1 );
+ add_filter( 'the_content', array( $this, 'filter_content_images' ), 10, 1 );
+
+
+ add_filter( 'map_meta_cap', array( $this, 'prevent_auto_updates' ), 10, 2 );
add_filter( 'default_avatar_select', array( $this, 'default_avatar' ) );
// Kill all the http requests.
@@ -145,7 +148,7 @@ private function __construct() {
add_filter( 'airplane_mode_parse_style', array( $this, 'bypass_asset_block' ), 10, 2 );
add_filter( 'airplane_mode_parse_script', array( $this, 'bypass_asset_block' ), 10, 2 );
- // Our activation / deactivation triggers.
+ // Our activation / deactivation triggers.
register_activation_hook( __FILE__, array( $this, 'create_setting' ) );
register_deactivation_hook( __FILE__, array( $this, 'remove_setting' ) );
@@ -211,7 +214,7 @@ private function __construct() {
// Add back the upload tab.
add_action( 'install_themes_upload', 'install_themes_upload', 10, 0 );
- // Define core contants for more protection.
+ // Define core contants for more protection.
if ( ! defined( 'AUTOMATIC_UPDATER_DISABLED' ) ) {
define( 'AUTOMATIC_UPDATER_DISABLED', true );
}
@@ -472,7 +475,7 @@ public function replace_gravatar( $avatar, $id_or_email, $size, $default, $alt )
}
// Swap out the file for a base64 encoded image.
- $image = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
+ $image = self::get_local_image_url();
$avatar = "";
// Return the avatar.
@@ -1257,6 +1260,34 @@ public function count_http_requests() {
$this->http_count++;
}
+ /**
+ * Generates a url to a locally stored image.
+ * Note: The actual SVG needs to be replaced with something licensed for distribution.
+ *
+ * @return string url to the airplane svg image.
+ */
+ public static function get_local_image_url() {
+ return plugin_dir_url( plugin_basename( __FILE__ ) ) . 'lib/img/airplane.svg';
+ }
+
+ /**
+ * Filters for instance of an image tag in the content, and replaces with local image.
+ *
+ * @param string $content the post content.
+ * @return mixed
+ */
+ public function filter_content_images($content ) {
+ if ( \preg_match_all('#]*)>#i', $content, $matches ) ) {
+ foreach ( $matches[0] as $match ) {
+ if ( \preg_match_all('#]*)src="([^"]*)#i', $match, $image_url ) ) {
+ preg_match_all('#]*)sizes="([^"]*)(max-width: (\d+)px)#i', $match, $image_size );
+ $content = \str_replace($image_url[2], sprintf('%s" width="%spx', self::get_local_image_url(), $image_size[4][0] ), $content );
+ }
+ }
+ }
+ return $content;
+ }
+
// End class.
}
diff --git a/lib/img/airplane.svg b/lib/img/airplane.svg
new file mode 100644
index 0000000..ab979f1
--- /dev/null
+++ b/lib/img/airplane.svg
@@ -0,0 +1,4 @@
+