Last active
August 29, 2015 14:16
-
-
Save yoren/cb406775a40a8d983b6d to your computer and use it in GitHub Desktop.
Add target attribute to image link
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 | |
//... | |
function my_add_link_target( $html ) { | |
$html = preg_replace( '/(<a.*")>/', '$1 target="_self">', $html ); | |
return $html; | |
} | |
add_filter( 'image_send_to_editor', 'my_add_link_target', 10 ); |
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
<a href="http://localhost/jsonapi/wp-content/uploads/2014/11/city-q-c-1024-768-4.jpg" target="_self"> | |
<img src="http://localhost/jsonapi/wp-content/uploads/2014/11/city-q-c-1024-768-4-300x225.jpg" alt="city-q-c-1024-768-4" width="300" height="225" class="alignnone size-medium wp-image-16" /> | |
</a> |
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
<a href="http://localhost/jsonapi/wp-content/uploads/2014/11/city-q-c-1024-768-4.jpg"> | |
<img src="http://localhost/jsonapi/wp-content/uploads/2014/11/city-q-c-1024-768-4-300x225.jpg" alt="city-q-c-1024-768-4" width="300" height="225" class="alignnone size-medium wp-image-16" /> | |
</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment