I was asked to look into a problem on a WordPress page that I didn’t make. It uses Visual Composer and for a few days they can’t add any images to the pages in the backend. The Single Image component loads, you can select the picture, but when you add it nothing happens.
Checking the console it gives the following error:
ReferenceError: id is not defined
in the following location: /wp-admin/load-scripts.php?c=0&load%5B%5D=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-draggable,jquery-ui-slider,jquery-tou&load%5B%5D=ch-punch,iris,wp-color-picker,jquery-ui-sortable,underscore,wp-a11y,thickbox,shortcode,plupload,jquery-ui-position,jquery-ui-men&load%5B%5D=u,jquery-ui-autocomplete,jquery-ui-tabs,farbtastic,media-upload&ver=4.5.2 line 98 > Function
var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};
with(obj||{}){
__p+='n <li class="added">n <div class="inner" style="width: 75px; height: 75px; overflow: hidden;text-align: center;">n <img rel="'+
((__t=( id ))==null?'':__t)+
'" src="'+
((__t=( url ))==null?'':__t)+
'" />n </div>n <a href="#" class="icon-remove"></a>n </li>n';
}
return __p;
Tried to fix it by this, this, this and this solution, but nothing worked.
I encountered this error today. It’s caused by updating to wordpress 4.5, which includes a new version of jquery which is incompatible with this old version of visual composer.
I was able to fix this by updating to a newer version of visual composer, which I found from this answer: https://stackoverflow.com/a/37138448
I also had the same problem today with a friend who created her own website in wordpress, updated wordpress and stopped working Visual Composer.
To resolve the issue quickly, I have modified the media-editor.js file, row 144 (media.VcSingleImage, set function)
I have replaced this row:
this.$img_ul.html(_.template($('#vc_settings-image-block').html(), selection));
with
this.$img_ul.html("<li class='add ui-sortable-handle'><img rel='"+selection.id+"' src='"+selection.url+"' > <a href='#' class='icon-remove'></a> </li>");
Let’s mention that at version Visual Composer is: 4.7.4
My friend had the same problem but with customized visual composer for Salient theme. I created full wp backup, enabled default theme, deleted Salient theme, downloaded zip file with original theme (from themeforest.net where he purchased it) and uploaded it in the Appearance / Themes / Add new / Upload theme view and enabled Salient Visual Composer plugin in the Plugins area…