Support

Home Forums Event Espresso Premium Insert Image not working

Insert Image not working

Posted: August 22, 2012 at 5:44 pm

Viewing 7 reply threads


yuri mejia

August 22, 2012 at 5:44 pm

I am attempting to integrate the this plugin and add-ons into an existing wordpress installation. The trouble seems to be with the “insert image” functions in all areas of the plugin itself. I can open the box and select an image, but upon clicking the “insert into” it just goes blank and nothing happens.

enter image description here

I have traced this down to being a conflict with the theme itself which is: Era – Visual Performance. I can gain the ability to upload an image by temporarily switching themes, but that’s not exactly a viable option.

My question is, has anyone else ever experienced this? Any ideas of where to start looking in the theme or possible mods to the plugin would be much appreciated. Everything else works geat, and I’d hate to see it all come down to something like this 😉

Thanks in advance

  • This topic was modified 12 years, 4 months ago by yuri mejia. Reason: grammar


Josh

  • Support Staff

August 22, 2012 at 8:19 pm

Hi Yuri,

I can recommend running the theme-check plugin, it will probably point you to where the theme isn’t using WordPress coding standards: http://wordpress.org/extend/plugins/theme-check/

It sounds like it might be running some of its JavaScript in the Event Espresso admin pages, so if you’re viewing the event editor in the admin, try checking the page in Firebug/web inspector for scripts loading from the theme. Then you can re-factor the theme so these do not load on any of the admin pages (except for the theme’s options pages if they’re required there of course.)


yuri mejia

August 28, 2012 at 1:41 pm

Thanks for the reply, but still no resolution yet. I’ve been through the admin with firebug a few times now and disabled every external script called by the theme leaving just the basic WP essentials, but still no joy. That insert image box just hangs there and doesn’t do anything.

ThemeChecker revealed a number of things that the original developer left behind, but nothing that looked like it would interfere with the plugin function.

It’s really starting to feel like a square peg in a round hole, and I’m not sure where to turn next. I hate the thought of abandoning the project as I already have quite a bit of time invested and still unable to get it running properly with this theme. Any other ideas or assistance would be greatly appreciated.

Thanks


Chris Reynolds

  • Support Staff

August 28, 2012 at 3:28 pm

What happens if you remove/comment out all javascript in the theme? More than likely the theme author is using a version of jQuery that is not being run in noConflict mode and, hence, causing conflicts with other jQuery that is being run according to WP standards.

http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_wrappers
https://eventespresso.com/2012/08/using-jquery-in-safe-mode/


yuri mejia

August 28, 2012 at 4:48 pm

Thanks for those tips!! I’m getting closer!!

The offending JS file in this theme is meta-box.js

JS Code:

jQuery(document).ready(function($) {



/** General metabox functions **/



// metabox checkbox styling

$('#side-sortables .rw-label').each(function() {

    var el = $(this);

    el.next('.rw-field:has(.rw-checkbox)').prev(el).addClass('rw-label-eracheck');

    $('.rw-label-eracheck').next('.rw-field').css('width', '32%');

});



// era metabox tooltips

$('.rw-field').each(function() {

    var t = $(this).find('div.desc-tooltip').remove(),

        ttext = t.html();



    $(this).parent().append(''+ttext+'');

    $('div.tooltip-icon').hover(function() {

        $(this).next('div.tooltip').fadeIn(200);

    }, function() {

        $(this).next('div.tooltip').fadeOut(200);

    });

});



// colorpicker field

$('.rw-color-picker').each(function(){

    var $this = $(this),

        id = $this.attr('rel');



    $this.farbtastic('#' + id);

});

$('.rw-color-select').click(function(){

    $(this).siblings('.rw-color-picker').toggle();

    return false;

});



// thickbox upload

$('.rw-upload-button').click(function(){

    var data = $(this).attr('rel').split('|'),

        post_id = data[0],

        field_id = data[1],

        backup = window.send_to_editor;     // backup the original 'send_to_editor' function which adds images to the editor



    // change the function to make it adds images to our section of uploaded images

    window.send_to_editor = function(html) {

        $('#rw-images-' + field_id).append($(html));



        tb_remove();

        window.send_to_editor = backup;

    };



    // note that we pass the field_id and post_id here

    tb_show('', 'media-upload.php?post_id=' + post_id + '&field_id=' + field_id + '&type=image&TB_iframe=true');



    return false;

});



// single image upload

window.formfield = '';

$('.era-upload-single-image').live('click', function() {

    window.formfield = $('.era-single-image', $(this).parent());

    tb_show('', 'media-upload.php?type=image&TB_iframe=true');

    return false;

});

window.original_send_to_editor = window.send_to_editor;

window.send_to_editor = function(html) {

    if (window.formfield) {

        imgurl = $('img', html).attr('src');

        window.formfield.val(imgurl);

        tb_remove();

    } else {

        window.original_send_to_editor(html);

    }

    window.formfield = '';

    window.imagefield = false;



    if($('.screenshot img').length) $('.screenshot img').attr('src', imgurl).css('display','block').next('a.remove').addClass('remove-on');

}



if($('.screenshot img').length) {

    $('.screenshot img').each(function() {

        var el = $(this);

        if(el.attr('src').length) {

            $(this).next('a.remove').addClass('remove-on');

        }

    });

    // Remove Uploaded Image

    $('.remove').live('click', function(event) { 

      $(this).parents('.rw-field').find('.era-single-image').attr('value', '');

      $(this).prev('img').fadeOut();

      $(this).removeClass('remove-on');

      event.preventDefault();

    });

}



// helper function

// get query string value by name, http://goo.gl/r0CH5

function get_query_var(name) {

    var match = RegExp('[?&]' + name + '=([^&#]*)').exec(location.href);



    return match && decodeURIComponent(match[1].replace(/\+/g, ' '));

}

The file calling it is metabox-class.php with this:
PHP Code:

// Load common js, css files for the script
function js_css() {
    $path = dirname(__FILE__); // get the path to the directory of current file

    // get URL of the directory of current file
    $base_url = ERA_THEME_URI . '/assets/theme_options/options/';

    wp_enqueue_style('rw-meta-box', $base_url . 'css/meta-box.css');
    wp_enqueue_script('rw-meta-box', $base_url . 'js/meta-box.js', array('jquery'), null, true);
}

I can make the plugin function properly when I comment it out. Is there a better option to make it compatible? Thank goodness a light at the end of the tunnel maybe.


Chris Reynolds

  • Support Staff

August 28, 2012 at 5:05 pm

I’m looking at this and wondering if this could be the problem since it’s also using Thickbox:

// thickbox upload
$('.rw-upload-button').click(function(){

    var data = $(this).attr('rel').split('|'),

        post_id = data[0],
        field_id = data[1],
        backup = window.send_to_editor;     // backup the original 'send_to_editor' function which adds images to the editor

    // change  the function to make it adds images to our section of uploaded images

    window.send_to_editor = function(html) {

        $('#rw-images-' + field_id).append($(html));

        tb_remove();

        window.send_to_editor = backup;
    };

    // note that we pass the field_id and post_id here

    tb_show('', 'media-upload.php?post_id=' + post_id + '&field_id=' + field_id + '&type=image&TB_iframe=true');

    return false;
});

You may be able to just remove that function (maybe) but you’ll probably break whatever theme functionality that’s trying to add.


yuri mejia

August 28, 2012 at 7:08 pm

OK, narrowing in further. It wasn’t the Thickbox function in the script.

Looks like this function is the one causing the problem:

JS Code:

if($('.screenshot img').length) {

    $('.screenshot img').each(function() {

        var el = $(this);

        if(el.attr('src').length) {

            $(this).next('a.remove').addClass('remove-on');

        }

    });

Any ideas?? I have yet to figure out this functions purpose. Commenting only this out seems to work, but I’m not sure where else it might be needed. Might just have to run with it and see what happens.


Chris Reynolds

  • Support Staff

August 29, 2012 at 10:22 am

I’d just run with it and see what happens. It will either come up eventually and you’ll say “oh that’s what that did” and then can deal with it then, or you won’t, and won’t even notice it’s gone. All this stuff has to do with adding screenshots to things (posts, I’m assuming) which may or may not be something you’re even using.

Viewing 7 reply threads

The support post ‘Insert Image not working’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso