0
Welcome Guest! Login
0 items Join Now

Wordpress RokStories Javascript Error

  • Wordpress RokStories Javascript Error

    Posted 12 years 5 months ago
    • When attempting to Upload/Insert an image into a Page HTML area I would get an error on line 13 of rokstories-admin.js. formfield is undefined or not an object. This is a variable scope issue that is solved by adding "var formfield;" to line 2 of the file so the variable is available to both the ".rokstories-image-upload" click event and the "window.send_to_editor" function.

      Complete code for file /wp-content/plugins/wp_rokstories/admin/rokstories-admin.js
       
      jQuery(function($){
           var formfield;
           // Image Upload Option
           jQuery('.rokstories-image-upload').click(function() {
                formfield = jQuery(this).attr('data-field-id');
                tb_show('', 'media-upload.php?type=image&TB_iframe=true');
                return false;
           });
       
           // Handles sending the image from the media uploader screen to the input field (for images)
           window.original_send_to_editor = window.send_to_editor;
           window.send_to_editor = function(html) {
                if(formfield) {
                     source = jQuery(html).find('img').attr('src');
                     jQuery('#'+formfield).val(source);
                     tb_remove();
                } else {
                     window.original_send_to_editor(html);
                }
           }
      });
       
    • Shazdeh's Avatar
    • Shazdeh
    • Elite Rocketeer
    • Posts: 4984
    • Thanks: 29

    Re: Wordpress RokStories Javascript Error

    Posted 12 years 5 months ago
    • Hi!
      This has been fixed in the new version of the plugin which is coming soon, but thank you for reporting the issue and providing a solution :P Very much appreciated.
    • Please don't PM unless requested ;)
      Consider using the custom stylesheet for all your CSS customizations: gantry-framework.org/documentation/wordp...custom_stylesheet.md .
      Please provide the URL to the issue.
      And please mark the thread as solved if the issue is resolved.

Time to create page: 0.048 seconds