Inserting image from custom imagegallery

Last post 08-07-2012, 7:51 AM by Minisuit. 2 replies.
Sort Posts: Previous Next
  •  06-11-2012, 2:34 AM 73865

    Inserting image from custom imagegallery

    Hi all
     
    I'm new here - and I might be posting this "problem" in the wrong place!
     
    I'm haveing some trouble inserting images from my own custom imagegallery into the editor, this is what I have done.
     
    A custom button
     
    $editor->CustomAddons = "<img title=\"Indsæt billede\" class=\"CuteEditorButton\" onmouseover=\"CuteEditor_ButtonCommandOver(this)\" onmouseout=\"CuteEditor_ButtonCommandOut(this)\" onmousedown=\"CuteEditor_ButtonCommandDown(this)\" onmouseup=\"CuteEditor_ButtonCommandUp(this)\" ondragstart=\"CuteEditor_CancelEvent()\" Command=\"billedarkiv\" src=\"../gfx/edit-gfx1.gif\" />";
    With the following javascript after
     
    <script language="JavaScript" type="text/javascript" >
       var editor1=document.getElementById("ClientID");
       function CuteEditor_OnCommand(editor1,command,ui,value) {
           //handle the command by yourself
           if(command=="billedarkiv") {
                  var newwin=editor1.ShowDialog(null,"../common/popup-billedarkiv_v2.0.php",editor1,"dialogWidth:800px;dialogHeight:600px");
                  return true;
           }
       }
    </script>
     
    When the user clicks the button, the dialog window loads perfectly, and I can select and add pictures to the gallery without problems.
     
    My script creates an html img tag, and I want to return this to the editor.
     
    My script looks like this
     
                echo "<script language='JavaScript' type='text/javascript'>\n";
                echo "<!--\n";
                echo " var imagename = '" . $imagename . "';\n";
                echo " var imagestring  = ('<img border=0 src=" . $billedarkivpath . "' + imagename + '\>');\n";
       
                echo "editor1.PasteHTML(imagestring);";
                echo "  window.close();\n";
                echo "// -->\n";
                echo "</script>\n";
     
    I think the problem has something to do with eidtor1.PasteHTML(imagestring) - and also I'm not sure how to close the window :)
     
    all/any help is appreaciated :)
     
    Best regards
    Bee (DK)
     
     
  •  06-12-2012, 3:32 AM 73874 in reply to 73865

    Re: Inserting image from custom imagegallery

    Hi - Problem solved :)
     
    I had a look at the file "custombuttons-popup.php" that illustrates how to do it - now it works perfectly :)
     
    Just thought I'd just mention it, if someone else should have the same problem.
     
    Best regards
    Bee (DK)
  •  08-07-2012, 7:51 AM 74356 in reply to 73874

    Re: Inserting image from custom imagegallery

    Step 1 Defining Custom Image Sizes
    For your theme to support custom image sizes you have to edit the functions.php file found in your themes folder. Open your theme’s functions.php and check if you have a line that looks like this:
    add_action( 'after_setup_theme', 'function_name' );  
    This hook is called during a theme’s initialization. It is generally used to perform basic setup, registration, and initialization actions for a theme, where “function_name” is the name of the function to be called.
    If you found a line like that, then also find the method with the same name as the 2nd parameter from that add_action method.
    If you can’t find a line that looks like that you should add it, and also create a method names as the 2nd parameter:
    add_action( 'after_setup_theme', 'setup' );  
    function setup() {  
        // ...  
    }  
    Now to enable post thumbnails for your theme add the following lines in the method defined above:
    function setup() {  
        // ...  
          
        add_theme_support( 'post-thumbnails' ); // This feature enables post-thumbnail support for a theme  
        // To enable only for posts:  
        //add_theme_support( 'post-thumbnails', array( 'post' ) );  
        // To enable only for posts and custom post types:  
        //add_theme_support( 'post-thumbnails', array( 'post', 'movie' ) );  
          
        // Register a new image size.  
        // This means that WordPress will create a copy of the post image with the specified dimensions  
        // when you upload a new image. Register as many as needed.  
        // Adding custom image sizes (name, width, height, crop)  
        add_image_size( 'featured-image', 620, 200, true );  
          
        // ...  
    }  
    Step 2 Displaying Images With Custom Sizes
    Insert Custom Sized Image Into Post Using Media Gallery
    To insert an image inside a post or page from the media gallery insert the following filter into the functions.php file:
    view plaincopy to clipboardprint?
    add_filter( 'image_size_names_choose', 'custom_image_sizes_choose' );  
    function custom_image_sizes_choose( $sizes ) {  
        $custom_sizes = array(  
            'featured-image' => 'Featured Image'  
        );  
        return array_merge( $sizes, $custom_sizes );  
    }  


    Best Regards,
    Navin Patel-Affiliate Manager
    Minisuit Affiliate Program
    Minisuit DOT com
View as RSS news feed in XML