title: Uncaught TypeError: $(...).size is not a function
body: <p>I'm using a plugin to insert an image from the file manager, however I'm getting an error:</p>
  <pre class="lang-none prettyprint-override"><code>imagebrowser.php?func=addImage&amp;w=160&amp;h=120:77 Uncaught TypeError: $(...).size is not a function
    at addImage (/site/dashboard/load.php?id=i18n_gallery&amp;create:564)
    at submitLink (imagebrowser.php?func=addImage&amp;w=160&amp;h=120:77)
    at HTMLAnchorElement.onclick (imagebrowser.php?func=addImage&amp;w=160&amp;h=120:53)
    addImage @ /site/dashboard/load.php?id=i18n_gallery&amp;create:564
    submitLink @ imagebrowser.php?func=addImage&amp;w=160&amp;h=120:77
    onclick @ imagebrowser.php?func=addImage&amp;w=160&amp;h=120:53
  </code></pre>
  <p>The JavaScript code I'm using:</p>
  <pre><code>    &lt;p&gt;&lt;em&gt;&lt;b&gt;&lt;?php echo count($filesSorted); ?&gt;&lt;/b&gt; &lt;?php i18n('TOTAL_FILES'); ?&gt; (&lt;?php echo fSize($totalsize); ?&gt;)&lt;/em&gt;&lt;/p&gt;
    &lt;p&gt;&lt;a href=&quot;javascript:void(0)&quot; onclick=&quot;submitAllLinks()&quot;&gt;&lt;?php i18n('i18n_gallery/ADD_ALL_IMAGES'); ?&gt;&lt;/a&gt;&lt;/p&gt;
    &lt;?php // foreach ($metadata as &amp;$m) if (!@$m['title']) $m['title'] = basename($m['url']); ?&gt;
    &lt;script type='text/javascript'&gt;
      // &lt;![CDATA[
      var metadata = &lt;?php echo json_encode($metadata); ?&gt;;
      function submitLink(i) {
        var item = metadata[i];
        if(window.opener){
          window.opener.&lt;?php echo $func; ?&gt;(item['url'], item['size'], item['width'], item['height'], item['title'], item['tags'], item['description']);
          &lt;?php if ($autoclose) { ?&gt;window.close();&lt;?php } ?&gt;
        }
      }
      function submitAllLinks() {
        for (var i=0; i &lt; metadata.length; i++) {
          submitLink(i);
        }
      }
      // ]]&gt;
    &lt;/script&gt;
  </code></pre>
  <p>EditExtra.php</p>
  <pre><code>&lt;?php
    global $id, $url, $parent;
  ?&gt;
  &lt;script type=&quot;text/javascript&quot;&gt;
    // &lt;![CDATA[
  &lt;?php
    $pages = return_i18n_pages();
    # tags
    $tags = array();
    foreach ($pages as $page) {
      foreach (preg_split('/\s*,\s*/', trim(@$page['tags'])) as $t) $tags[$t] = true;
    }
    $tags = array_keys($tags);
    sort($tags);
    # structure
    $structure = return_i18n_page_structure(null,false,$url);
    $siblings = @$pages[''.$parent]['children'];
    if ($siblings) $myindex = array_search($url, $siblings); else $myindex = false;
    $after = $myindex !== false &amp;&amp; $myindex &gt; 0 ? $siblings[$myindex-1] : '';
  ?&gt;
    var after = &lt;?php echo json_encode($after); ?&gt;;
    function changeParent() {
      $parent = $('#post-parent').val();
  &lt;?php
    $firstoption = '&lt;option value=&quot;0&quot;&gt;-- '.i18n_r('i18n_navigation/TOP').' --&lt;/option&gt;';
    $page = $pages[null];
    if (isset($page['children']) &amp;&amp; count($page['children']) &gt; 0) {
      $children = $page['children'];
      $options = '';
      for ($i=0; $i&lt;count($children); $i++) {
        if ($children[$i] != $url) $options .= '&lt;option value=&quot;'.$children[$i].'&quot;&gt;'.$pages[$children[$i]]['title'].'&lt;/option&gt;';
      }
  ?&gt;
      if ($parent == null || $parent == '') {
         $('#post-menu-order').empty().html(&lt;?php echo json_encode($firstoption.$options); ?&gt;);
  &lt;?php
    }
    foreach ($structure as $page) {
      $page = $pages[$page['url']];
      if (isset($page['children']) &amp;&amp; count($page['children']) &gt; 0) {
        $children = $page['children'];
        $options = '';
        for ($i=0; $i&lt;count($children); $i++) {
          if ($children[$i] != $url) $options .= '&lt;option value=&quot;'.$children[$i].'&quot;&gt;'.$pages[$children[$i]]['title'].'&lt;/option&gt;';
        }
  ?&gt;
      } else if ($parent == &lt;?php echo json_encode($page['url']); ?&gt;) {
         $('#post-menu-order').empty().html(&lt;?php echo json_encode($firstoption.$options); ?&gt;);
  &lt;?php
      }
    }
  ?&gt;
      } else {
         $('#post-menu-order').empty().html(&lt;?php echo json_encode($firstoption); ?&gt;);
      } 
      $('#post-menu-order').val(after);     
    }
    function changeUrl() {
      var url = $('#post-id').val();
      if ($('div.leftopt').length &gt; 0) { // GetSimple 3.0+
        var hide = url.indexOf('_') &gt;= 0;
        if (hide) {
          $('#post-parent').closest('p').hide();
          $('#post-private').closest('p').hide();
          $('#post-template').closest('p').hide();
          $('#post-menu-order').hide();
          $('#post-menu-order').prev().hide();
        }
      } else {
        if (url.indexOf('_') &gt;= 0) {
          $('#post-parent').closest('tr').attr('style','display:none');
          $('#post-private').closest('td').children().attr('style','display:none');
          //$('#post-menu-enable').attr('style','display:none');
          $('#post-menu').nextAll().attr('style','display:none');
        } else {
          $('#post-parent').closest('tr').attr('style',null);
          $('#post-private').closest('td').children().attr('style',null);
          //$('#post-menu-enable').attr('style',null);
          $('#post-menu').nextAll().attr('style',null);
        }
      }
    }
    var tags = &lt;?php echo json_encode($tags); ?&gt;;
    $(function() {
      $fParent = $('#post-parent');
      $fParent.empty();
      $fParent.append(&lt;?php echo json_encode('&lt;option value=&quot;&quot; '.($parent == null ? 'selected' : '').'&gt;-- '.i18n_r('NONE').' --&lt;/option&gt;'); ?&gt;);
  &lt;?php
    foreach ($structure as $page) {
  ?&gt;
      $fParent.append(&lt;?php echo json_encode('&lt;option value=&quot;'.$page['url'].'&quot; '.($parent == $page['url'] ? 'selected' : '').'&gt;'.($page['level'] &gt; 0 ? str_repeat(&quot;&amp;nbsp;&quot;,5*$page['level']-2).'&amp;lfloor;&amp;nbsp;' : '').cl($page['title']).'&lt;/option&gt;'); ?&gt;);
  &lt;?php
    }
  ?&gt;
      if ($('#tick').length &gt; 0) { // GetSimple 3.1+
        $('a.viewlink').hide();
        $('#menu-items').css('height','auto').css('padding-bottom','10px');
        $('#post-menu').attr('style','').addClass('short');
        $('#post-menu').prev().remove();
        $('#post-menu').prev().remove();
        $('#post-menu').prev().remove();
        $('#post-menu').before('&lt;span style=&quot;text-transform:none&quot;&gt;&lt;label for=&quot;post-menu&quot;&gt;' + &lt;?php echo json_encode(i18n_r('MENU_TEXT')); ?&gt; + '&lt;/label&gt;&lt;/span&gt;');
        $('#post-menu-order').attr('style','clear:both;').addClass('short');
        $('#post-menu-order').before('&lt;span style=&quot;text-transform:none;float:left;&quot;&gt;&lt;label for=&quot;post-menu&quot;&gt;' + &lt;?php echo json_encode(i18n_r('i18n_navigation/INSERT_AFTER')); ?&gt; + '&lt;/label&gt;&lt;/span&gt;');
      } else if ($('div.leftopt').length &gt; 0) { // GetSimple 3.0
        $('label[for=post-menu-enable]').nextUntil('input').remove();
        $('#menu-items').css('height','auto');
        $('#post-menu').attr('style','').addClass('short');
        $('#post-menu').prev().remove();
        $('#post-menu').prev().remove();
        $('#post-menu').prev().remove();
        $('#post-menu').before('&lt;label for=&quot;post-menu&quot;&gt;' + &lt;?php echo json_encode(i18n_r('MENU_TEXT')); ?&gt; + '&lt;/label&gt;');
        $('#post-menu-order').attr('style','').addClass('short');
        $('#post-menu-order').before('&lt;label for=&quot;post-menu&quot;&gt;' + &lt;?php echo json_encode(i18n_r('i18n_navigation/INSERT_AFTER')); ?&gt; + '&lt;/label&gt;');
      } else {
        $a = $('#post-menu-enable').closest('td').find('a');
        $a.after($a.html());
        $a.remove();
        $('#post-menu').closest('div').find('span').empty().html(&lt;?php echo json_encode(i18n_r('MENU_TEXT')); ?&gt;);
        $('#post-menu').attr('style','').after(&lt;?php echo json_encode('&lt;br /&gt;&lt;span&gt;'.i18n_r('i18n_navigation/INSERT_AFTER').'&lt;/span&gt;'); ?&gt;);
        $('#post-menu-order').attr('style','').before('&lt;br /&gt;');
      }  
      $('#post-parent').change(changeParent);
      $('#post-id').change(changeUrl);
      changeParent();
      changeUrl();
      $('#post-metak').autocomplete(tags, {
        minChars: 0,
        max: 50,
        scroll: true,
        multiple: true,
        multipleSeparator: ', '
      });
    });
    // ]]&gt;
  &lt;/script&gt;
  </code></pre>
  <p>This is what I suspected as the main error reason after investigation:</p>
  <pre><code>if ($('#tick').size() &gt; 0) {
  </code></pre>
  <p>But replacing it with <code>length</code> didn't resolve the issue.</p>
  <p>jQuery version:  jquery-3.2.1.min.js?v=3.2.1</p>