Last active
August 31, 2022 16:33
-
-
Save selul/8279bfcfe611b68515eaab4d8a16efbf to your computer and use it in GitHub Desktop.
Redirect Yoast attachments redirects to Optimole urls.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Plugin Name: Optimole Tweak - Redirect Yoast attachments to Optimole urls. | |
* Version: 0.0.1 | |
*/ | |
add_filter( 'wpseo_attachment_redirect_url', function ( $url ) { | |
return apply_filters( 'optml_content_url', $url ); | |
}, 999 ); | |
add_filter( 'attachment_link', function ( $url, $id ) { | |
if ( is_admin() ) { | |
return $url; | |
} | |
return wp_get_attachment_image_url( $id, 'full' ); | |
}, 999, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment