Title: Script Errors
Last modified: August 31, 2016

---

# Script Errors

 *  [cjhmdm](https://wordpress.org/support/users/cjhmdm/)
 * (@cjhmdm)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/script-errors-3/)
 * Hello, I’d like to use your plugin but upon activating and attempting to create
   a gallery, I receive the following errors:
 * Uncaught TypeError: Cannot read property ‘src’ of undefined
    Uncaught TypeError:
   Cannot read property ‘top’ of undefined
 * From here:
    `var Tiles={};(function($){var Tile=Tiles.Tile=function(tileId,element){
   this.id=tileId;this.top=0;this.left=0;this.width=0;this.height=0;this.$el=$(element
   ||document.createElement("div"))};Tile.prototype.appendTo=function($parent,fadeIn,
   delay,duration){this.$el.hide().appendTo($parent);if(fadeIn){this.$el.delay(delay).
   fadeIn(duration)}else{this.$el.show()}};Tile.prototype.remove=function(animate,
   duration){if(animate){this.$el.fadeOut({complete:function(){$(this).remove()}})}
   else{this.$el.remove()}};Tile.prototype.resize=function(cellRect,pixelRect,animate,
   duration,onComplete){var cssChanges={},changed=false;if(this.left!==pixelRect.
   x){cssChanges.left=pixelRect.x;this.left=pixelRect.x;changed=true}if(this.top!
   ==pixelRect.y){cssChanges.top=pixelRect.y;this.top=pixelRect.y;changed=true}if(
   this.width!==pixelRect.width){cssChanges.width=pixelRect.width;this.width=pixelRect.
   width;changed=true}if(this.height!==pixelRect.height){cssChanges.height=pixelRect.
   height;this.height=pixelRect.height;changed=true}var tile=this,validateChangesAndComplete
   =function(){var el=tile.$el[0];if(tile.left!==el.offsetLeft){tile.$el.css("left",
   tile.left)}if(tile.top!==el.offsetTop){tile.$el.css("top",tile.top)}if(onComplete){
   onComplete()}};if(animate&&changed){this.$el.animate(cssChanges,{duration:duration,
   easing:"swing",complete:validateChangesAndComplete})}else{if(changed){this.$el.
   css(cssChanges)}setTimeout(validateChangesAndComplete,duration)}}})(jQuery);(
   function($){var parseCells=function(rows){var cells=[],numRows=rows.length,x,
   y,row,rowLength,cell;for(y=0;y<numRows;y++){row=rows[y];cells[y]=[];for(x=0,rowLength
   =row.length;x<rowLength;x++){cell=row[x];if(cell!==" "){cells[y].push(cell)}}}
   return cells};function Rectangle(x,y,width,height){this.x=x;this.y=y;this.width
   =width;this.height=height}Rectangle.prototype.copy=function(){return new Rectangle(
   this.x,this.y,this.width,this.height)};Tiles.Rectangle=Rectangle;var parseRects
   =function(cells){var rects=[],numRows=cells.length,numCols=numRows===0?0:cells[
   0].length,cell,height,width,x,y,rectX,rectY;cells=cells.slice();for(y=0;y<numRows;
   y++){cells[y]=cells[y].slice()}for(y=0;y<numRows;y++){for(x=0;x<numCols;x++){
   cell=cells[y][x];if(cell==null){continue}width=1;height=1;if(cell!==Tiles.Template.
   SINGLE_CELL){while(width+x<numCols&&cell===cells[y][x+width]){width++}while(height
   +y<numRows&&cell===cells[y+height][x]){height++}}for(rectY=0;rectY<height;rectY
   ++){for(rectX=0;rectX<width;rectX++){cells[y+rectY][x+rectX]=null}}rects.push(
   new Rectangle(x,y,width,height))}}return rects};Tiles.Template=function(rects,
   numCols,numRows){this.rects=rects;this.numTiles=this.rects.length;this.numRows
   =numRows;this.numCols=numCols};Tiles.Template.prototype.copy=function(){var copyRects
   =[],len,i;for(i=0,len=this.rects.length;i<len;i++){copyRects.push(this.rects[
   i].copy())}return new Tiles.Template(copyRects,this.numCols,this.numRows)};Tiles.
   Template.prototype.append=function(other){if(this.numCols!==other.numCols){throw"
   Appended templates must have the same number of columns"}var startY=this.numRows,
   i,len,rect;for(i=0,len=other.rects.length;i<len;i++){rect=other.rects[i];this.
   rects.push(new Rectangle(rect.x,startY+rect.y,rect.width,rect.height))}this.numRows
   +=other.numRows;this.numTiles+=other.numTiles};Tiles.Template.fromJSON=function(
   rows){var cells=parseCells(rows),rects=parseRects(cells);return new Tiles.Template(
   rects,cells.length>0?cells[0].length:0,cells.length)};Tiles.Template.prototype.
   toJSON=function(){var LABELS="ABCDEFGHIJKLMNOPQRSTUVWXYZ",NUM_LABELS=LABELS.length,
   labelIndex=0,rows=[],i,len,rect,x,y,label;for(y=0;y<this.numRows;y++){rows[y]
   =[];for(x=0;x<this.numCols;x++){rows[y][x]=Tiles.Template.SINGLE_CELL}}for(i=
   0,len=this.rects.length;i<len;i++){rect=this.rects[i];if(rect.width>1||rect.height
   >1){label=LABELS[labelIndex];for(y=0;y<rect.height;y++){for(x=0;x<rect.width;
   x++){rows[rect.y+y][rect.x+x]=label}}labelIndex=(labelIndex+1)%NUM_LABELS}}for(
   y=0;y<this.numRows;y++){rows[y]=rows[y].join("")}return rows};Tiles.Template.
   SINGLE_CELL="."})(jQuery);Tiles.UniformTemplates={get:function(numCols,targetTiles){
   var numRows=Math.ceil(targetTiles/numCols),rects=[],x,y;for(y=0;y<numRows;y++){
   for(x=0;x<numCols;x++){rects.push(new Tiles.Rectangle(x,y,1,1))}}return new Tiles.
   Template(rects,numCols,numRows)}};(function($){var Grid=Tiles.Grid=function(element){
   this.$el=$(element);this.animationDuration=500;this.cellSizeMin=150;this.templateFactory
   =Tiles.UniformTemplates;this.priorityPageSize=Number.MAX_VALUE;this.cellPadding
   =10;this.cellSize=0;this.numCols=1;this.template=null;this.isDirty=true;this.
   tiles=[];this.tilesAdded=[];this.tilesRemoved=[]};Grid.prototype.getContentWidth
   =function(){return this.$el.width()};Grid.prototype.resizeColumns=function(){
   var panelWidth=this.getContentWidth();return Math.max(1,Math.floor((panelWidth
   +this.cellPadding)/(this.cellSizeMin+this.cellPadding)))};Grid.prototype.resizeCellSize
   =function(){var panelWidth=this.getContentWidth();return Math.ceil((panelWidth
   +this.cellPadding)/this.numCols)-this.cellPadding};Grid.prototype.resize=function(){
   var newCols=this.resizeColumns();if(this.numCols!==newCols&&newCols>0){this.numCols
   =newCols;this.isDirty=true}var newCellSize=this.resizeCellSize();if(this.cellSize!
   ==newCellSize&&newCellSize>0){this.cellSize=newCellSize;this.isDirty=true}};Grid.
   prototype.updateTiles=function(newTileIds){newTileIds=uniques(newTileIds);var
   numTiles=newTileIds.length,newTiles=[],i,tile,tileId,index;for(i=this.tiles.length-
   1;i>=0;i--){tile=this.tiles[i];index=$.inArray(tile.id,newTileIds);if(index<0){
   this.tilesRemoved.push(tile)}else{newTiles[index]=tile}}this.tiles=[];for(i=0;
   i<numTiles;i++){tile=newTiles[i];if(!tile){tileId=newTileIds[i];if(this.createTile){
   tile=this.createTile(tileId);if(!tile){continue}}else{tile=new Tiles.Tile(tileId)}
   this.tilesAdded.push(tile)}this.tiles.push(tile)}};function uniques(items){var
   results=[],numItems=items?items.length:0,i,item;for(i=0;i<numItems;i++){item=
   items[i];if($.inArray(item,results)===-1){results.push(item)}}return results}
   Grid.prototype.insertTiles=function(newTileIds){this.addTiles(newTileIds,true)};
   Grid.prototype.addTiles=function(newTileIds,prepend){if(!newTileIds||newTileIds.
   length===0){return}var prevTileIds=[],prevTileCount=this.tiles.length,i;for(i
   =0;i<prevTileCount;i++){prevTileIds.push(this.tiles[i].id)}var tileIds=prepend?
   newTileIds.concat(prevTileIds):prevTileIds.concat(newTileIds);this.updateTiles(
   tileIds)};Grid.prototype.removeTiles=function(removeTileIds){if(!removeTileIds
   ||removeTileIds.length===0){return}var updateTileIds=[],i,len,id;for(i=0,len=
   this.tiles.length;i<len;i++){id=this.tiles[i].id;if($.inArray(id,removeTileIds)
   ===-1){updateTileIds.push(id)}}this.updateTiles(updateTileIds)};Grid.prototype.
   createTemplate=function(numCols,targetTiles){numCols=Math.max(1,numCols);var 
   template=this.templateFactory.get(numCols,targetTiles);if(!template){template
   =Tiles.UniformTemplates.get(numCols,targetTiles)}return template};Grid.prototype.
   ensureTemplate=function(numTiles){if(!this.template||this.template.numCols!==
   this.numCols){this.template=this.createTemplate(this.numCols,numTiles);this.isDirty
   =true}else{var missingRects=numTiles-this.template.rects.length;if(missingRects
   >0){this.template.append(this.createTemplate(this.numCols,missingRects));this.
   isDirty=true}}};function wasOrWillBeVisible(viewRect,tile,newRect){var viewMaxY
   =viewRect.y+viewRect.height,viewMaxX=viewRect.x+viewRect.width;if(tile){if(!(
   tile.top>viewMaxY||tile.top+tile.height<viewRect.y||tile.left>viewMaxX||tile.
   left+tile.width<viewRect.x)){return true}}if(newRect){if(!(newRect.y>viewMaxY
   ||newRect.y+newRect.height<viewRect.y||newRect.x>viewMaxX||newRect.x+newRect.
   width<viewRect.x)){return true}}return false}Grid.prototype.shouldRedraw=function(){
   if(this.cellSize<=0){this.resize()}this.ensureTemplate(this.tiles.length);var
   shouldRedraw=this.isDirty||this.tilesAdded.length>0||this.tilesRemoved.length
   >0;return shouldRedraw};Grid.prototype.redraw=function(animate,onComplete){if(!
   this.shouldRedraw()){if(onComplete){onComplete(false)}return}var numTiles=this.
   tiles.length,pageSize=this.priorityPageSize,duration=this.animationDuration,cellPlusPadding
   =this.cellSize+this.cellPadding,tileIndex=0,appendDelay=0,viewRect=new Tiles.
   Rectangle(this.$el.scrollLeft(),this.$el.scrollTop(),this.$el.width(),this.$el.
   height()),tile,added,pageRects,pageTiles,i,len,cellRect,pixelRect,animateTile,
   priorityRects,priorityTiles;for(tileIndex=0;tileIndex<numTiles;tileIndex+=pageSize){
   pageRects=this.template.rects.slice(tileIndex,tileIndex+pageSize);pageTiles=this.
   tiles.slice(tileIndex,tileIndex+pageSize);priorityRects=pageRects.slice(0);priorityTiles
   =pageTiles.slice(0);if(this.prioritizePage){this.prioritizePage(priorityRects,
   priorityTiles)}for(i=0,len=priorityTiles.length;i<len;i++){tile=priorityTiles[
   i];added=$.inArray(tile,this.tilesAdded)>=0;cellRect=priorityRects[i];pixelRect
   =new Tiles.Rectangle(cellRect.x*cellPlusPadding,cellRect.y*cellPlusPadding,cellRect.
   width*cellPlusPadding-this.cellPadding,cellRect.height*cellPlusPadding-this.cellPadding);
   tile.resize(cellRect,pixelRect,animate&&!added&&wasOrWillBeVisible(viewRect,tile,
   pixelRect),duration);if(added){animateTile=animate&&wasOrWillBeVisible(viewRect,
   null,pixelRect);if(animateTile&&this.getAppendDelay){appendDelay=this.getAppendDelay(
   cellRect,pageRects,priorityRects,tile,pageTiles,priorityTiles)}else{appendDelay
   =0}tile.appendTo(this.$el,animateTile,appendDelay,duration)}}}for(i=0,len=this.
   tilesRemoved.length;i<len;i++){tile=this.tilesRemoved[i];animateTile=animate&&
   wasOrWillBeVisible(viewRect,tile,null);tile.remove(animateTile,duration)}this.
   tilesRemoved=[];this.tilesAdded=[];this.isDirty=false;if(onComplete){setTimeout(
   function(){onComplete(true)},duration+10)}}})(jQuery);(function($,undef){if($.
   fn.dotdotdot){return}$.fn.dotdotdot=function(o){if(this.length==0){$.fn.dotdotdot.
   debug('No element found for "'+this.selector+'".');return this}if(this.length
   >1){return this.each(function(){$(this).dotdotdot(o)})}var $dot=this;if($dot.
   data("dotdotdot")){$dot.trigger("destroy.dot")}$dot.data("dotdotdot-style",$dot.
   attr("style")||"");$dot.css("word-wrap","break-word");if($dot.css("white-space")
   ==="nowrap"){$dot.css("white-space","normal")}$dot.bind_events=function(){$dot.
   bind("update.dot",function(e,c){e.preventDefault();e.stopPropagation();opts.maxHeight
   =typeof opts.height=="number"?opts.height:getTrueInnerHeight($dot);opts.maxHeight
   +=opts.tolerance;if(typeof c!="undefined"){if(typeof c=="string"||c instanceof
   HTMLElement){c=$("<div />").append(c).contents()}if(c instanceof $){orgContent
   =c}}$inr=$dot.wrapInner('<div class="dotdotdot" />').children();$inr.contents().
   detach().end().append(orgContent.clone(true)).find("br").replaceWith(" <br />").
   end().css({height:"auto",width:"auto",border:"none",padding:0,margin:0});var 
   after=false,trunc=false;if(conf.afterElement){after=conf.afterElement.clone(true);
   after.show();conf.afterElement.detach()}if(test($inr,opts)){if(opts.wrap=="children"){
   trunc=children($inr,opts,after)}else{trunc=ellipsis($inr,$dot,$inr,opts,after)}}
   $inr.replaceWith($inr.contents());$inr=null;if($.isFunction(opts.callback)){opts.
   callback.call($dot[0],trunc,orgContent)}conf.isTruncated=trunc;return trunc}).
   bind("isTruncated.dot",function(e,fn){e.preventDefault();e.stopPropagation();
   if(typeof fn=="function"){fn.call($dot[0],conf.isTruncated)}return conf.isTruncated}).
   bind("originalContent.dot",function(e,fn){e.preventDefault();e.stopPropagation();
   if(typeof fn=="function"){fn.call($dot[0],orgContent)}return orgContent}).bind("
   destroy.dot",function(e){e.preventDefault();e.stopPropagation();$dot.unwatch().
   unbind_events().contents().detach().end().append(orgContent).attr("style",$dot.
   data("dotdotdot-style")||"").data("dotdotdot",false)});return $dot};$dot.unbind_events
   =function(){$dot.unbind(".dot");return $dot};$dot.watch=function(){$dot.unwatch();
   if(opts.watch=="window"){var $window=$(window),_wWidth=$window.width(),_wHeight
   =$window.height();$window.bind("resize.dot"+conf.dotId,function(){if(_wWidth!
   =$window.width()||_wHeight!=$window.height()||!opts.windowResizeFix){_wWidth=
   $window.width();_wHeight=$window.height();if(watchInt){clearInterval(watchInt)}
   watchInt=setTimeout(function(){$dot.trigger("update.dot")},100)}})}else{watchOrg
   =getSizes($dot);watchInt=setInterval(function(){if($dot.is(":visible")){var watchNew
   =getSizes($dot);if(watchOrg.width!=watchNew.width||watchOrg.height!=watchNew.
   height){$dot.trigger("update.dot");watchOrg=watchNew}}},500)}return $dot};$dot.
   unwatch=function(){$(window).unbind("resize.dot"+conf.dotId);if(watchInt){clearInterval(
   watchInt)}return $dot};var orgContent=$dot.contents(),opts=$.extend(true,{},$.
   fn.dotdotdot.defaults,o),conf={},watchOrg={},watchInt=null,$inr=null;if(!(opts.
   lastCharacter.remove instanceof Array)){opts.lastCharacter.remove=$.fn.dotdotdot.
   defaultArrays.lastCharacter.remove}if(!(opts.lastCharacter.noEllipsis instanceof
   Array)){opts.lastCharacter.noEllipsis=$.fn.dotdotdot.defaultArrays.lastCharacter.
   noEllipsis}conf.afterElement=getElement(opts.after,$dot);conf.isTruncated=false;
   conf.dotId=dotId++;$dot.data("dotdotdot",true).bind_events().trigger("update.
   dot");if(opts.watch){$dot.watch()}return $dot};$.fn.dotdotdot.defaults={ellipsis:"...",
   wrap:"word",fallbackToLetter:true,lastCharacter:{},tolerance:0,callback:null,
   after:null,height:null,watch:false,windowResizeFix:true};$.fn.dotdotdot.defaultArrays
   ={lastCharacter:{remove:[" ","　",",",";",".","!","?"],noEllipsis:[]}};$.fn.dotdotdot.
   debug=function(msg){};var dotId=1;function children($elem,o,after){var $elements
   =$elem.children(),isTruncated=false;$elem.empty();for(var a=0,l=$elements.length;
   a<l;a++){var $e=$elements.eq(a);$elem.append($e);if(after){$elem.append(after)}
   if(test($elem,o)){$e.remove();isTruncated=true;break}else{if(after){after.detach()}}}
   return isTruncated}function ellipsis($elem,$d,$i,o,after){var isTruncated=false;
   var notx="table, thead, tbody, tfoot, tr, col, colgroup, object, embed, param,
   ol, ul, dl, blockquote, select, optgroup, option, textarea, script, style";var
   noty="script";$elem.contents().detach().each(function(){var e=this,$e=$(e);if(
   typeof e=="undefined"||e.nodeType==3&&$.trim(e.data).length==0){return true}else
   if($e.is(noty)){$elem.append($e)}else if(isTruncated){return true}else{$elem.
   append($e);if(after){$elem[$elem.is(notx)?"after":"append"](after)}if(test($i,
   o)){if(e.nodeType==3){isTruncated=ellipsisElement($e,$d,$i,o,after)}else{isTruncated
   =ellipsis($e,$d,$i,o,after)}if(!isTruncated){$e.detach();isTruncated=true}}if(!
   isTruncated){if(after){after.detach()}}}});return isTruncated}function ellipsisElement(
   $e,$d,$i,o,after){var e=$e[0];if(!e){return false}var txt=getTextContent(e),space
   =txt.indexOf(" ")!==-1?" ":"　",separator=o.wrap=="letter"?"":space,textArr=txt.
   split(separator),position=-1,midPos=-1,startPos=0,endPos=textArr.length-1;if(
   o.fallbackToLetter&&startPos==0&&endPos==0){separator="";textArr=txt.split(separator);
   endPos=textArr.length-1}while(startPos<=endPos&&!(startPos==0&&endPos==0)){var
   m=Math.floor((startPos+endPos)/2);if(m==midPos){break}midPos=m;setTextContent(
   e,textArr.slice(0,midPos+1).join(separator)+o.ellipsis);if(!test($i,o)){position
   =midPos;startPos=midPos}else{endPos=midPos;if(o.fallbackToLetter&&startPos==0&&
   endPos==0){separator="";textArr=textArr[0].split(separator);position=-1;midPos
   =-1;startPos=0;endPos=textArr.length-1}}}if(position!=-1&&!(textArr.length==1&&
   textArr[0].length==0)){txt=addEllipsis(textArr.slice(0,position+1).join(separator),
   o);setTextContent(e,txt)}else{var $w=$e.parent();$e.detach();var afterLength=
   after&&after.closest($w).length?after.length:0;if($w.contents().length>afterLength){
   e=findLastTextNode($w.contents().eq(-1-afterLength),$d)}else{e=findLastTextNode(
   $w,$d,true);if(!afterLength){$w.detach()}}if(e){txt=addEllipsis(getTextContent(
   e),o);setTextContent(e,txt);if(afterLength&&after){$(e).parent().append(after)}}}
   return true}function test($i,o){return $i.innerHeight()>o.maxHeight}function 
   addEllipsis(txt,o){while($.inArray(txt.slice(-1),o.lastCharacter.remove)>-1){
   txt=txt.slice(0,-1)}if($.inArray(txt.slice(-1),o.lastCharacter.noEllipsis)<0){
   txt+=o.ellipsis}return txt}function getSizes($d){return{width:$d.innerWidth(),
   height:$d.innerHeight()}}function setTextContent(e,content){if(e.innerText){e.
   innerText=content}else if(e.nodeValue){e.nodeValue=content}else if(e.textContent){
   e.textContent=content}}function getTextContent(e){if(e.innerText){return e.innerText}
   else if(e.nodeValue){return e.nodeValue}else if(e.textContent){return e.textContent}
   else{return""}}function getPrevNode(n){do{n=n.previousSibling}while(n&&n.nodeType!
   ==1&&n.nodeType!==3);return n}function findLastTextNode($el,$top,excludeCurrent){
   var e=$el&&$el[0],p;if(e){if(!excludeCurrent){if(e.nodeType===3){return e}if(
   $.trim($el.text())){return findLastTextNode($el.contents().last(),$top)}}p=getPrevNode(
   e);while(!p){$el=$el.parent();if($el.is($top)||!$el.length){return false}p=getPrevNode(
   $el[0])}if(p){return findLastTextNode($(p),$top)}}return false}function getElement(
   e,$i){if(!e){return false}if(typeof e==="string"){e=$(e,$i);return e.length?e:
   false}return!e.jquery?false:e}function getTrueInnerHeight($el){var h=$el.innerHeight(),
   a=["paddingTop","paddingBottom"];for(var z=0,l=a.length;z<l;z++){var m=parseInt(
   $el.css(a[z]),10);if(isNaN(m)){m=0}h-=m}return h}var _orgHtml=$.fn.html;$.fn.
   html=function(str){if(str!=undef&&!$.isFunction(str)&&this.data("dotdotdot")){
   return this.trigger("update",[str])}return _orgHtml.apply(this,arguments)};var
   _orgText=$.fn.text;$.fn.text=function(str){if(str!=undef&&!$.isFunction(str)&&
   this.data("dotdotdot")){str=$("<div />").text(str).html();return this.trigger("
   update",[str])}return _orgText.apply(this,arguments)}})(jQuery);(function($){
   $.wptiles={debounce:function(func,wait,immediate){var timeout;return function(){
   var context=this,args=arguments;var later=function(){timeout=null;if(!immediate)
   func.apply(context,args)};if(immediate&&!timeout)func.apply(context,args);clearTimeout(
   timeout);timeout=setTimeout(later,wait)}},resizeParent:function($el,padding){
   var tiles=$el.children(".wp-tiles-tile"),tileOffsetTop=parseInt($el.offset().
   top),max=0,newHeight;tiles.each(function(){var $e=$(this),bottom=$e.height()+
   $e.offset().top;if(bottom>max)max=bottom});newHeight=max-tileOffsetTop+parseInt(
   padding)+"px";$el.parent(".wp-tiles-container").css("height",newHeight)}};$.fn.
   extend({wptiles:function(opts){var $el=$(this),$templates=$("#"+opts.id+"-templates"),
   $pagination=$("#"+opts.id+"-pagination"),grid,curr_large_template=false,using_small
   =false,get_first_grid=function(){var grid;$.each(opts.grids,function(){grid=this;
   return false});return grid},get_template=function(){var is_small;if(!curr_large_template)
   curr_large_template=get_first_grid();if(!opts.breakpoint)return curr_large_template;
   is_small=$el.width()<opts.breakpoint;if(is_small&&!using_small){$templates.hide();
   using_small=true;return opts.small_screen_grid}else if(!is_small&&using_small){
   $templates.show();using_small=false;return curr_large_template}return is_small?
   opts.small_screen_grid:curr_large_template},set_template=function(template){curr_large_template
   =template;grid.template=template},onresize=function(){$.wptiles.resizeParent(
   $el,opts.padding);$(".wp-tiles-byline").dotdotdot();$el.trigger("wp-tiles:resize")},
   style_tiles=function(){var set_bylines_color=function($bylines,color){$bylines.
   css("color",color);$bylines.find(":header").css("color",color)},$image_bylines
   =$(".wp-tiles-tile-with-image .wp-tiles-byline",$el);if($image_bylines.get(0)){
   if("random"!==opts.byline_color){$image_bylines.css("background-color",opts.byline_color)}
   $image_bylines.css(opts.byline_height_auto?"max-height":"height",opts.byline_height
   +"%");if(opts.image_text_color){set_bylines_color($image_bylines,opts.image_text_color)}}
   if(opts.text_color){var $text_only_bylines=$(".wp-tiles-tile-text-only .wp-tiles-
   byline",$el);if($text_only_bylines.get(0)){set_bylines_color($text_only_bylines,
   opts.text_color)}}};$el.addClass("wp-tiles-loaded");if(opts.breakpoint)opts.small_screen_grid
   =Tiles.Template.fromJSON(opts.small_screen_grid);var grids={};$.each(opts.grids,
   function(key){grids[key]=Tiles.Template.fromJSON(this)});opts.grids=grids;grid
   =$.extend(new Tiles.Grid($el),{cellPadding:parseInt(opts.padding),template:get_template(),
   templateFactory:{get:function(numCols,numTiles){var template=get_template().copy(),
   missingRects=numTiles-template.rects.length;while(missingRects>0){var copyRects
   =[],i,t=get_template().copy();if(missingRects<=t.rects.length){copyRects=t.rects;
   missingRects=0}else{for(i=0;i<t.rects.length;i++){copyRects.push(t.rects[i].copy())}
   missingRects-=t.rects.length}template.append(new Tiles.Template(copyRects,t.numCols,
   t.numRows))}return template}},resizeColumns:function(){return this.template.numCols},
   createTile:function(data){var tile=new Tiles.Tile(data.id,data),$el=tile.$el,
   i=parseInt(data.id.match(/[0-9]{1,}/)),color=opts.colors[i%opts.colors.length];
   $el.css("background-color",color);if($(".wp-tiles-tile-with-image",$el).get(0)){
   if("random"===opts.byline_color){var $byline=$(".wp-tiles-byline",$el),alpha=
   opts.byline_opacity,rgb=color,rgbx=rgb.substr(0,4)==="rgba"?rgb:rgb.replace("
   rgb","rgba").replace(")",","+alpha+")"),comma=rgbx.lastIndexOf(","),rgba=rgbx.
   slice(0,comma+1)+alpha+")";$byline.css("background-color",rgba)}var $bg_img=$(".
   wp-tiles-tile-bg .wp-tiles-img",$el),bg_img_src=$bg_img[0].src;$(".wp-tiles-tile-
   bg",$el).css({"background-image":"url('"+bg_img_src+"')","-ms-filter":"progid:
   DXImageTransform.Microsoft.AlphaImageLoader( src='"+bg_img_src+"', sizingMethod
   ='scale')",filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader( src='"
   +bg_img_src+"', sizingMethod='scale')"});$bg_img.first().remove()}return tile},
   nextPage:function(){if(!opts.next_query)return;if(typeof grid.nextPage.running!
   =="undefined"&&grid.nextPage.running)return;grid.nextPage.running=true;$pagination.
   addClass("loading");if(!opts.next_query.opts){opts.next_query.opts={};$.each(["
   hide_title","link","byline_template","byline_template_textonly","images_only","
   image_size","text_only","link_new_window"],function(){opts.next_query.opts[this]
   =opts[this]})}$.post(opts.ajaxurl,opts.next_query).success(function(response){
   if("-1"==response){$pagination.fadeOut(function(){$pagination.removeClass("loading")})}
   if(response.has_more){opts.next_query.query.paged++;opts.next_query._ajax_nonce
   =response._ajax_nonce;$pagination.removeClass("loading")}else{opts.next_query
   =false;$pagination.fadeOut(function(){$pagination.removeClass("loading")})}var
   tiles=$("<div />").html(response.tiles).find(".wp-tiles-tile").get();grid.addTiles(
   tiles);grid.redraw(opts.animate_template,onresize);style_tiles();grid.nextPage.
   running=false})}});var $posts=$(".wp-tiles-tile",$el);grid.updateTiles($posts);
   grid.redraw(opts.animate_init,onresize);style_tiles();$(window).resize($.wptiles.
   debounce(function(){grid.template=get_template();grid.isDirty=true;grid.resize();
   grid.redraw(opts.animate_resize,onresize)},200));if($templates.get(0)){var $templateButtons
   =$(".wp-tiles-template",$templates);$templateButtons.css("background-color",opts.
   grid_selector_color);$templateButtons.on("click",function(e){e.preventDefault();
   $templateButtons.removeClass("selected");$(this).addClass("selected");var rows
   =opts.grids[$(this).data("grid")];set_template(rows);grid.isDirty=true;grid.resize();
   grid.redraw(opts.animate_template,onresize)})}if($pagination.get(0)){if($pagination.
   hasClass("wp-tiles-pagination-ajax")){$pagination.click(function(e){e.preventDefault();
   grid.nextPage()})}}opts.grid=grid}});if(typeof wptilesdata==="object"){$(function(){
   $.each(wptilesdata,function(){var tiledata=this,$el=$("#"+tiledata.id);$el.wptiles(
   tiledata)});$(window).trigger("resize")})}})(jQuery);`
 * [https://wordpress.org/plugins/wp-tiles/](https://wordpress.org/plugins/wp-tiles/)

The topic ‘Script Errors’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-tiles_8f8e84.svg)
 * [WP Tiles](https://wordpress.org/plugins/wp-tiles/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-tiles/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-tiles/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-tiles/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-tiles/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-tiles/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [cjhmdm](https://wordpress.org/support/users/cjhmdm/)
 * Last activity: [10 years, 4 months ago](https://wordpress.org/support/topic/script-errors-3/)
 * Status: not resolved