Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_filter('the_content', 'brentini_addthickboxclass');
- function brentini_addthickboxclass($content) {
- add_thickbox();
- $pattern[0] ="/<a(.*?)href=('|\")(.*?).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>/i";
- $replacement[0] = '<a$1href=$2$3.$4$5 class="thickbox">';
- $pattern[1] = "/(<a href=)('|\")([^\>]*?)(\.bmp|\.gif|\.jpg|\.jpeg|\.png)('|\")([^\>]*?)(>)(.*?) title=('|\")(.*?)('|\")(.*?)(<\/a>)/i";
- $replacement[1] = '$1$2$3$4$5$6 title=$9$10$11$7$8 title=$9$10$11$12$13';
- $pattern[2] = "/(<a href=)('|\")([^\>]*?)(\.bmp|\.gif|\.jpg|\.jpeg|\.png)('|\")([^\>]*?) title=([^\>]*?) title=([^\>]*?)(>)(.*?)(<\/a>)/i";
- $replacement[2] = '$1$2$3$4$5$6 title=$7$9$10$11';
- $content = preg_replace($pattern, $replacement, $content);
- return $content;
- }
- function brentini_add_thickbox_class_to_head(){
- {?>
- <script type="text/javascript">jQuery(document).ready(function($){
- $('dt.gallery-icon a').addClass('thickbox');
- });</script>
- <?php }}
- add_action('wp_head', 'brentini_add_thickbox_class_to_head');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement