Changeset 1185
- Timestamp:
- 07/23/08 04:31:41 (4 months ago)
- Files:
-
- bb-attachments/trunk/bb-attachments.php (modified) (6 diffs)
- bb-attachments/trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
bb-attachments/trunk/bb-attachments.php
r1183 r1185 6 6 Author: _ck_ 7 7 Author URI: http://bbShowcase.org 8 Version: 0.1. 58 Version: 0.1.6 9 9 10 10 License: CC-GNU-GPL http://creativecommons.org/licenses/GPL/2.0/ … … 66 66 add_action( 'bb_init', 'bb_attachments_init'); 67 67 add_action( 'bb_post.php', 'bb_attachments_process_post'); 68 add_filter( 'bb_allowed_tags', 'bb_attachments_extra_tags' );68 add_filter('post_text', 'bb_attachments_bbcode',250); 69 69 bb_register_activation_hook( __FILE__, 'bb_attachments_install'); 70 70 … … 121 121 122 122 function bb_attachments_add_css() { global $bb_attachments; echo '<style type="text/css">'.$bb_attachments['style'].'</style>';} // inject css 123 124 function bb_attachments_extra_tags( $tags ) {if (!isset($tags['img'])) {$tags['img'] = array('src' => array(), 'title' => array(), 'alt' => array());} return $tags;}125 123 126 124 function bb_attachments($post_id=0) { … … 206 204 $fullpath=$bb_attachments['path'].floor($file->id/1000)."/".$attachment->id.".".$attachment->filename; 207 205 if (list($width, $height, $type) = getimagesize($fullpath)) { 208 $output.=" [<strong><a href='#' onclick='bbat t_inline_insert($attachment->post_id,$attachment->id); return false;'>".__("INSERT")."</a></strong>] ";206 $output.=" [<strong><a href='#' onclick='bbat_inline_insert($attachment->post_id,$attachment->id); return false;'>".__("INSERT")."</a></strong>] "; 209 207 } 210 208 } … … 216 214 if ($output) {$output="<h3>".__("Attachments")."</h3><ol>".$output."</ol>";} 217 215 if ($location="edit.php") { 218 $output.='<scr'.'ipt type="text/javascript" defer="defer">function bbatt_inline_insert(post_id,id) { 219 myField=document.getElementsByTagName("textarea")[0]; 220 tmp="?bb_attachments="+post_id+"&bbat="+id; q="'."'".'"; 221 myValue="<a href="+q+tmp+q+"><img src="+q+tmp+"&inline"+q+"></a>"; 216 $output.='<scr'.'ipt type="text/javascript" defer="defer">function bbat_inline_insert(post_id,id) { 217 myValue="[attachment="+post_id+","+id+"]"; 222 218 if (document.selection) {myField.focus();sel = document.selection.createRange();sel.text = myValue;} 223 219 else if (myField.selectionStart || myField.selectionStart == "0") {var startPos = myField.selectionStart; var endPos = myField.selectionEnd; … … 228 224 } 229 225 return $output; 226 } 227 228 function bb_attachments_bbcode($text) { 229 $text = preg_replace("/\[attachment=([0-9]+?)\,([0-9]+?)\]/sim","<a href='?bb_attachments=$1&bbat=$2'><img src='?bb_attachments=$1&bbat=$2&inline'></a>",$text); 230 return $text; 230 231 } 231 232 bb-attachments/trunk/readme.txt
r1181 r1185 52 52 * 0.1.1 role check before hooks, ability to disable upload on new posts if compatibility issues 53 53 * 0.1.5 first attempt at inline image display ability 54 * 0.1.6 BBcode replacement for inserted inline attachment 54 55 55 56 == To Do ==
