Changeset 1185

Show
Ignore:
Timestamp:
07/23/08 04:31:41 (4 months ago)
Author:
_ck_
Message:

0.1.6 now uses BBcode to insert inline images

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • bb-attachments/trunk/bb-attachments.php

    r1183 r1185  
    66Author: _ck_ 
    77Author URI: http://bbShowcase.org 
    8 Version: 0.1.5 
     8Version: 0.1.6 
    99 
    1010License: CC-GNU-GPL http://creativecommons.org/licenses/GPL/2.0/ 
     
    6666add_action( 'bb_init', 'bb_attachments_init'); 
    6767add_action( 'bb_post.php', 'bb_attachments_process_post'); 
    68 add_filter( 'bb_allowed_tags', 'bb_attachments_extra_tags' ); 
     68add_filter('post_text', 'bb_attachments_bbcode',250);   
    6969bb_register_activation_hook( __FILE__,  'bb_attachments_install'); 
    7070 
     
    121121 
    122122function 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;} 
    125123 
    126124function bb_attachments($post_id=0) { 
     
    206204                                        $fullpath=$bb_attachments['path'].floor($file->id/1000)."/".$attachment->id.".".$attachment->filename; 
    207205                                        if (list($width, $height, $type) = getimagesize($fullpath)) {                                                            
    208                                                 $output.=" [<strong><a href='#' onclick='bbatt_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>] ";    
    209207                                        } 
    210208                                }                                                
     
    216214if ($output) {$output="<h3>".__("Attachments")."</h3><ol>".$output."</ol>";} 
    217215if ($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+"]"; 
    222218        if (document.selection) {myField.focus();sel = document.selection.createRange();sel.text = myValue;} 
    223219        else if (myField.selectionStart || myField.selectionStart == "0") {var startPos = myField.selectionStart; var endPos = myField.selectionEnd; 
     
    228224} 
    229225return $output; 
     226} 
     227 
     228function 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); 
     230return $text; 
    230231} 
    231232 
  • bb-attachments/trunk/readme.txt

    r1181 r1185  
    5252* 0.1.1 role check before hooks, ability to disable upload on new posts if compatibility issues 
    5353* 0.1.5 first attempt at inline image display ability 
     54* 0.1.6 BBcode replacement for inserted inline attachment 
    5455         
    5556== To Do ==