WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Custom Field Template] Conflict with Faster Imager Insert Plugin (4 posts)

  1. Flick
    Member
    Posted 2 years ago #

    Our blog is very image heavy and uses the Faster Image Insert plugin to insert all the images for a post into the content quickly. Since installing the Custom Field Template plugin the Multiple Image Insert won't work. It only inserts the first image.

    Switching off the Custom Field Template plugin makes the Faster Image Insert plugin work again.

    Is there a work around or better plugin than Faster Image Insert?

    They need to live together!!

  2. David Frank
    Member
    Posted 2 years ago #

    I think this issue has been visible enough to worth an investigation.

    Will work on it when I have time, let us know how did you insert the image with CPT? Is it still through the same editing panel like normal?

    We had a workaround in FII 1.x series but apparent it breaks somewhere along the line...

  3. Flick
    Member
    Posted 2 years ago #

    Thanks for that! The Faster Image Insert plugin was breaking when you try and get it to put the multiple images into the main Editor. After a bit of research I worked out that the potential conflict was the 'media_send_to_editor' filter.

    I simply commented out line 95 in custom-field-template.php and it fixed the conflict. Faster Image Insert plugin works and I can't see any problems with CFT either.

    Line 95 is:
    //add_filter( 'media_send_to_editor', array(&$this, 'media_send_to_custom_field'), 15 );

    I use the Media Picker and Insert Image items in Custom Field Template... what was this filter for? Is it needed?

    Thanks for looking into it!

  4. David Frank
    Member
    Posted 2 years ago #

    Hi All,

    I have been looking into the conflict between CPT and FII that cause multiple insert to fail, currently a resolution looks difficult (not possible without plugin author's collaboration), here is why:

    FII use a little trick to allow it to send newline into the editing panel, this requires a filter to overcome the current media manager insert limit:

    //used for passing content to edit panel.
    function fast_insert_to_editor($html) {
    ?>
    <script type="text/javascript">
    /* <![CDATA[ */
    var win = window.dialogArguments || opener || parent || top;
    win.send_to_editor('<?php echo str_replace('\\\n','\\n',addslashes($html)); ?>');
    /* ]]> */
    </script>
      <?php
      exit;
    }

    on the other hand, CPT utilize their own trick as well:

    function media_send_to_custom_field($html) {
    		$out =  '<script type="text/javascript">' . "\n" .
    					'	/* <![CDATA[ */' . "\n" .
    					'	var win = window.dialogArguments || opener || parent || top;' . "\n" .
    					'   if ( typeof win.send_to_custom_field == "function" ) ' . "\n" .
    					'	    win.send_to_custom_field("' . addslashes($html) . '");' . "\n" .
    					'   else ' . "\n" .
    					'       win.send_to_editor("' . addslashes($html) . '");' . "\n" .
    					'/* ]]> */' . "\n" .
    					'</script>' . "\n";
    
    		echo $out;

    What this means is that only one of the plugin can be in charge of sending the data to editing panel. Unless there is a compatible way of doing so, user has to pick one plugin's functionality over the other.

    flick's workaround comes at a price, but if you are not using CPT's insert function that extensively, it's an acceptable price.

    I really hope WP3.3 improve its media manager in the "editing" direction, but as far as I can tell with 3.3 beta2, their focus has been the uploader.

Topic Closed

This topic has been closed to new replies.

About this Topic