Plugin Directory

Changeset 965282


Ignore:
Timestamp:
08/13/2014 07:56:54 PM (11 years ago)
Author:
johannesfosseus
Message:

Adding first version of my plugin

Location:
related-images/trunk
Files:
10 added
3 edited

Legend:

Unmodified
Added
Removed
  • related-images/trunk/readme.txt

    r456488 r965282  
    11=== Related Images ===
    2 Contributors: Johannes Fosseus
     2Contributors: johannesfosseus
    33Tags: images, related images, cms
    4 Requires at least: 3.1
    5 Tested up to: 3.4 beta2
     4Requires at least: 3.5
     5Tested up to: 4.0 beta3
    66
    77The plugin creates a backend box where you can search your media archive and relate images to the current post to a given position.
  • related-images/trunk/related-images.class.php

    r456488 r965282  
    8282
    8383    }
    84    
     84
    8585    // returne the "default" post_id, not the revision
    8686    function get_correct_post_id($post_id){
    87        
     87
    8888        $post_id_parent = get_post($post_id)->post_parent;
    8989
     
    9999    function save_related_images($post_id){
    100100        global $wpdb;
    101        
     101
    102102        // allways use the "default" post_id, not the revision one
    103103        $post_id = $this->get_correct_post_id($post_id);
    104        
     104
    105105        // get saved positions
    106106        if($_POST['saved_img_position']){
     
    156156                        $class = " class=\"".$class."\"";
    157157                    }
    158                    
     158
    159159                    echo "<img src=\"".$image_data['img_url']."\" ".$image_data['img_h_w']."".$class.">"; // add h & w
    160160
     
    203203                // add the url
    204204                $img['img_url'] = $image;
    205                
     205
    206206                // get w/h
    207207                if ($data = @getimagesize($image)) {
    208208                    $size = getimagesize($image);
    209                     $img['img_h_w'] = $size[3];                 
     209                    $img['img_h_w'] = $size[3];
    210210                }
    211211
     
    293293            die();
    294294        }
    295        
     295
    296296        // get the search string
    297297        $img_id = $_POST['img_id'];
    298298        $post_ID = $_POST['post_ID'];
    299        
     299
    300300        // get saved options
    301301        $related_images = get_option($post_ID."_related_images");
    302        
     302
    303303        // if there is only one saved, remove it all, or unset a specific image and then update the options
    304304        $len = sizeof($related_images);
    305        
     305
    306306        if($related_images == 1){
    307307            delete_option($post_ID."_related_images");
    308         } else {   
     308        } else {
    309309            unset($related_images[$img_id]);
    310310            update_option($post_ID."_related_images", $related_images);
    311311        }
    312        
    313         die();     
    314        
    315     }
    316    
    317    
     312
     313        die();
     314
     315    }
     316
     317
    318318    // run the search
    319319    function do_image_search(){
  • related-images/trunk/related-images.php

    r391641 r965282  
    33Plugin Name: Related Images
    44Plugin URI: http://www.fosseus.se
    5 Description: Relate one or more images to a post
     5Description: Relate and position one or more images to a post. Ever wanted to relate images and display images och various positions to a post? This is the plugin for you.
    66Author: johannesfosseus
    7 Version: 1.2.3
     7Author URI: http://profiles.wordpress.org/johannesfosseus/
     8Version: 2.0
    89*/
    910
    10 // load the class
    11 require_once dirname( __FILE__ ) . '/related-images.class.php';
    12 if (class_exists('RelatedImages')){
    13     $related_images = new RelatedImages();
     11/**
     12 * Constants
     13 */
     14define( 'RI_VERSION', '2' );
     15define( 'RI_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
     16define( 'RI_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
     17define( 'RI_TPL_DIR', RI_PLUGIN_DIR.'tpl/' );
     18
     19
     20/**
     21 * Include required classes
     22 */
     23require( 'inc/class-config.php' );
     24require( 'inc/class-tpl.php' );
     25
     26if( is_admin() ) {
     27    require( 'inc/class-backend.php' );
     28} else {
     29    require( 'inc/class-frontend.php' );
    1430}
    15 
    16 // backend stuff
    17 if(is_admin()){
    18     wp_enqueue_script('related_images_js', WP_PLUGIN_URL.'/related-images/related-images.js', array('jquery'));
    19     wp_enqueue_style('related_images_css', WP_PLUGIN_URL.'/related-images/style.css');
    20     add_action('wp_ajax_search_related_images',  array($related_images, 'do_image_search')); // do the search
    21     add_action('wp_ajax_remove_related_images',  array($related_images, 'remove_image')); // remove a image
    22 }
    23 
    24 // frontend template tag
    25 function related_image($position, $width, $height, $class = '', $crop = ''){
    26     global $related_images;
    27     echo $related_images->print_image($position, $width, $height, $class, $crop);
    28 }
    29 ?>
Note: See TracChangeset for help on using the changeset viewer.