<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Search Results Default Featured Image in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/Search-Results-Default-Featured-Image/m-p/540259#M26457</link>
    <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/204643"&gt;@LSeth&lt;/a&gt;&amp;nbsp;in the Hubspot search results module that you've cloned, there's this function addResult. You need to add an else statement to the bit that sets the featured image if it's undefined.&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;function addResult(title, url, description, featuredImage) {
      var newResult = document.importNode(resultTemplate.content, true);
      function isFeaturedImageEnabled() {
        if (
          newResult.querySelector('.hs-search-results__featured-image &amp;gt; img')
        ) {
          return true;
        }
      }
      newResult.querySelector('.hs-search-results__title').innerHTML = title;
      newResult.querySelector('.hs-search-results__title').href = url;
      newResult.querySelector(
        '.hs-search-results__description'
      ).innerHTML = description;
      if (typeof featuredImage !== 'undefined' &amp;amp;&amp;amp; isFeaturedImageEnabled()) {
        newResult.querySelector(
          '.hs-search-results__featured-image &amp;gt; img'
        ).src=featuredImage;
      } else {
        // add else statement to set featured image to placeholder if there is no featured image
        newResult.querySelector(
          '.hs-search-results__featured-image &amp;gt; img'
        ).src='[url of placeholder image]';
      }
      resultsSection.appendChild(newResult);
    }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 10 Dec 2021 12:05:16 GMT</pubDate>
    <dc:creator>piersg</dc:creator>
    <dc:date>2021-12-10T12:05:16Z</dc:date>
    <item>
      <title>Search Results Default Featured Image</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Search-Results-Default-Featured-Image/m-p/539885#M26452</link>
      <description>&lt;P&gt;I am setting a search results based on the Search Results Module that I have cloned. I am bringing in featured images, is there a way that I can set an image that would be the featured image if the post/page in the results has no featured image? Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Dec 2021 20:50:24 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Search-Results-Default-Featured-Image/m-p/539885#M26452</guid>
      <dc:creator>LSeth</dc:creator>
      <dc:date>2021-12-09T20:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: Search Results Default Featured Image</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Search-Results-Default-Featured-Image/m-p/540026#M26454</link>
      <description>&lt;P&gt;Hi LSeth, this is Grant,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can &lt;A href="https://developers.hubspot.com/docs/cms/hubl/variables" target="_blank" rel="noopener"&gt;set featured images through HubL&lt;/A&gt;. The featured image and the alt text. Once you've found the posts without through your search module, the featured image varibale needs a URL to the featured image you want to use. Set it and forget it : )&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Screen Shot 2021-12-09 at 7.53.00 PM.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/55452i9C055A533C1BD5B4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2021-12-09 at 7.53.00 PM.png" alt="Screen Shot 2021-12-09 at 7.53.00 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, you can reference previous, as well as next post's featured image.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Onward,&lt;/P&gt;&lt;P&gt;Grant&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://revpartners.io" target="_blank" rel="noopener"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Grant Carlile" style="width: 200px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/55961i2792DC9109F9B47C/image-size/small?v=v2&amp;amp;px=200" role="button" title="Grant Carlile RP + Green Shirt.png" alt="Grant Carlile" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Grant Carlile&lt;/span&gt;&lt;/span&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Grant Carlile, RevOps Developer&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://revpartners.io/" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;RevPartners&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt; is an unmatched team of operators who design and execute revenue engines to supercharge your growth.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.grantcarlile.com/schedule" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="RP Schedule 20 min with me.png" style="width: 200px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/55962i271E8D5A403A6D46/image-size/small?v=v2&amp;amp;px=200" role="button" title="RP Schedule 20 min with me.png" alt="RP Schedule 20 min with me.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Dec 2021 02:36:12 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Search-Results-Default-Featured-Image/m-p/540026#M26454</guid>
      <dc:creator>GrantCarlile</dc:creator>
      <dc:date>2021-12-17T02:36:12Z</dc:date>
    </item>
    <item>
      <title>Re: Search Results Default Featured Image</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Search-Results-Default-Featured-Image/m-p/540029#M26455</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/204643"&gt;@LSeth&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Mind posting the code that you have so far?&amp;nbsp; What you will want is an &lt;A href="https://developers.hubspot.com/docs/cms/hubl/if-statements?hsLang=en" target="_blank" rel="noopener"&gt;if statement&lt;/A&gt; checking to see if there is a featured image.&amp;nbsp; If not, display a default image.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 01:15:35 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Search-Results-Default-Featured-Image/m-p/540029#M26455</guid>
      <dc:creator>dennisedson</dc:creator>
      <dc:date>2021-12-10T01:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: Search Results Default Featured Image</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Search-Results-Default-Featured-Image/m-p/540259#M26457</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/204643"&gt;@LSeth&lt;/a&gt;&amp;nbsp;in the Hubspot search results module that you've cloned, there's this function addResult. You need to add an else statement to the bit that sets the featured image if it's undefined.&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;function addResult(title, url, description, featuredImage) {
      var newResult = document.importNode(resultTemplate.content, true);
      function isFeaturedImageEnabled() {
        if (
          newResult.querySelector('.hs-search-results__featured-image &amp;gt; img')
        ) {
          return true;
        }
      }
      newResult.querySelector('.hs-search-results__title').innerHTML = title;
      newResult.querySelector('.hs-search-results__title').href = url;
      newResult.querySelector(
        '.hs-search-results__description'
      ).innerHTML = description;
      if (typeof featuredImage !== 'undefined' &amp;amp;&amp;amp; isFeaturedImageEnabled()) {
        newResult.querySelector(
          '.hs-search-results__featured-image &amp;gt; img'
        ).src=featuredImage;
      } else {
        // add else statement to set featured image to placeholder if there is no featured image
        newResult.querySelector(
          '.hs-search-results__featured-image &amp;gt; img'
        ).src='[url of placeholder image]';
      }
      resultsSection.appendChild(newResult);
    }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 12:05:16 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Search-Results-Default-Featured-Image/m-p/540259#M26457</guid>
      <dc:creator>piersg</dc:creator>
      <dc:date>2021-12-10T12:05:16Z</dc:date>
    </item>
    <item>
      <title>Re: Search Results Default Featured Image</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Search-Results-Default-Featured-Image/m-p/540301#M26459</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/103660"&gt;@piersg&lt;/a&gt;&amp;nbsp;I tried your else statement and it does not work. It's almost like the if statement is always true regardless of whether there is a featured image or not and does not get to the else statement you provided.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 13:39:23 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Search-Results-Default-Featured-Image/m-p/540301#M26459</guid>
      <dc:creator>LSeth</dc:creator>
      <dc:date>2021-12-10T13:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: Search Results Default Featured Image</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Search-Results-Default-Featured-Image/m-p/540302#M26460</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/13982"&gt;@dennisedson&lt;/a&gt;&amp;nbsp;The code is the Hubspot search module. I just cloned it so I can make the needed modifications.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 13:40:28 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Search-Results-Default-Featured-Image/m-p/540302#M26460</guid>
      <dc:creator>LSeth</dc:creator>
      <dc:date>2021-12-10T13:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: Search Results Default Featured Image</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Search-Results-Default-Featured-Image/m-p/540316#M26462</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/103660"&gt;@piersg&lt;/a&gt;&amp;nbsp;Sorry your code does work. I typed it in incorrectly. Thanks for the assist.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 14:02:29 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Search-Results-Default-Featured-Image/m-p/540316#M26462</guid>
      <dc:creator>LSeth</dc:creator>
      <dc:date>2021-12-10T14:02:29Z</dc:date>
    </item>
    <item>
      <title>Re: Search Results Default Featured Image</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Search-Results-Default-Featured-Image/m-p/540320#M26463</link>
      <description>&lt;P&gt;Nicely done adding the code snippet to make it clear. Streamlined solution too.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Grant Carlile" style="width: 200px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/55449i78FE0E06722CDF71/image-size/small?v=v2&amp;amp;px=200" role="button" title="Grant Carlile RP + Green Shirt.png" alt="Grant Carlile" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Grant Carlile&lt;/span&gt;&lt;/span&gt;&lt;STRONG&gt;Grant Carlile, RevOps Developer&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;A title="RevPartners.io" href="https://revpartners.io" target="_blank" rel="noopener"&gt;RevPartners&lt;/A&gt; is an unmatched team of operators who design and execute revenue engines to supercharge your growth.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A title="This is Grant" href="https://www.grantcarlile.com/schedule" target="_blank" rel="noopener"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="RP Schedule 20 min with me.png" style="width: 200px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/55498i3D1696EFB45004EF/image-size/small?v=v2&amp;amp;px=200" role="button" title="RP Schedule 20 min with me.png" alt="RP Schedule 20 min with me.png" /&gt;&lt;/span&gt;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 14:13:49 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Search-Results-Default-Featured-Image/m-p/540320#M26463</guid>
      <dc:creator>GrantCarlile</dc:creator>
      <dc:date>2021-12-10T14:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: Search Results Default Featured Image</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Search-Results-Default-Featured-Image/m-p/540330#M26464</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/204643"&gt;@LSeth&lt;/a&gt;&amp;nbsp;Haha classic, we've all been there&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 14:31:39 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Search-Results-Default-Featured-Image/m-p/540330#M26464</guid>
      <dc:creator>piersg</dc:creator>
      <dc:date>2021-12-10T14:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: Search Results Default Featured Image</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Search-Results-Default-Featured-Image/m-p/540513#M26470</link>
      <description>&lt;P&gt;.........&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;function addResult(title, url, description, featuredImage) {
      var newResult = document.importNode(resultTemplate.content, true);
      function isFeaturedImageEnabled() {
        if (
          newResult.querySelector('.hs-search-results__featured-image &amp;gt; img')
        ) {
          return true;
        }
      }
      newResult.querySelector('.hs-search-results__title').innerHTML = title;
      newResult.querySelector('.hs-search-results__title').href = url;
      newResult.querySelector(
        '.hs-search-results__description'
      ).innerHTML = description;
      if (typeof featuredImage !== 'undefined' &amp;amp;&amp;amp; isFeaturedImageEnabled()) {
        newResult.querySelector(
          '.hs-search-results__featured-image &amp;gt; img'
        ).src=featuredImage;
      } else {
        // add else statement to set featured image to placeholder if there is no featured image
        newResult.querySelector(
          '.hs-search-results__featured-image &amp;gt; img'
        ).src='[url of placeholder image]';
      }
      resultsSection.appendChild(newResult);
    }&lt;/LI-CODE&gt;&lt;P&gt;Why....?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;      newResult.querySelector('.hs-search-results__title').innerHTML = title;
      newResult.querySelector('.hs-search-results__title').href = url;
    &lt;/LI-CODE&gt;&lt;P&gt;Redundant....&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;      function isFeaturedImageEnabled() {
        if (
          newResult.querySelector('.hs-search-results__featured-image &amp;gt; img')
        ) {
          return true;
        }
      }
    &lt;/LI-CODE&gt;&lt;P&gt;Why...?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;      function isFeaturedImageEnabled() {
        if (newResult.querySelector('.hs-search-results__featured-image &amp;gt; img') {
          return true;
        }
      }
       ... 
        newResult.querySelector(
          '.hs-search-results__featured-image &amp;gt; img'
        ).src=featuredImage;
       ...
          newResult.querySelector(
          '.hs-search-results__featured-image &amp;gt; img'
        ).src='[url of placeholder image]';
     &lt;/LI-CODE&gt;&lt;P&gt;I could keep going. Bad code samples are not helpful. They only proliferate bad code and standards.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Dec 2021 19:07:02 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Search-Results-Default-Featured-Image/m-p/540513#M26470</guid>
      <dc:creator>ThemeMajer</dc:creator>
      <dc:date>2021-12-10T19:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: Search Results Default Featured Image</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Search-Results-Default-Featured-Image/m-p/542296#M26506</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/262527"&gt;@ThemeMajer&lt;/a&gt;, I merely edited the code from current default Hubspot search results module, that the OP said they were using. I did it this way to make it easy for the OP to understand; I only added three lines, where I put the comment "add else statement...", I didn't write the whole function.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Dec 2021 19:30:12 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Search-Results-Default-Featured-Image/m-p/542296#M26506</guid>
      <dc:creator>piersg</dc:creator>
      <dc:date>2021-12-14T19:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: Search Results Default Featured Image</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Search-Results-Default-Featured-Image/m-p/542472#M26508</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/103660"&gt;@piersg&lt;/a&gt;&amp;nbsp;No worries. Should've been explicit rather than dumping code. Was just musing at the quality of a core module used on X production websites etc was.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And sure minification blah blah blah, but people rely *way* too much on automated processes for everything (webpack, etc).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;These have their place, but shaking processes and minification are still subject to the authors artistry. And we're the author to have taken greater care you'd see significantly improved minification etc even in some of the largest open source projects there are.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was turning my nose up at something I considered.... Lacking and view as being far too prolific in code everywhere&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Dec 2021 03:19:24 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Search-Results-Default-Featured-Image/m-p/542472#M26508</guid>
      <dc:creator>ThemeMajer</dc:creator>
      <dc:date>2021-12-15T03:19:24Z</dc:date>
    </item>
  </channel>
</rss>

