CodeSlinger83 Posted March 1, 2023 Share Posted March 1, 2023 I would like to remove the file name text that is displayed on the Search Results page. When I search for the word "broccoli" the returned results show the .png image file name as well. I do not want these image files to be shown in the search results, I would like only the text of the page, and/or any description of the page, such as the SEO description if one exists, to be displayed here. Link to comment
tuanphan Posted March 5, 2023 Share Posted March 5, 2023 Add to Settings > Advanced > Code Injection > Footer <!-- Remove jpg in search page --> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script> <script> const attrObserver = new MutationObserver((mutations) => { mutations.forEach((mu) => { if (mu.type !== "attributes" && mu.attributeName !== "class") return; trimEXT(); }); }); const ELS_test = document.querySelectorAll(".search-results"); ELS_test.forEach((el) => attrObserver.observe(el, { attributes: true })); function trimEXT() { $(".search-results img").ready(function () { $(".sqs-search-page .sqs-title").html(function () { return $(this).html().replace(".jpg", "").replace(".png", "").replace(".jpeg", ""); }); }); } $(document).ready(function () { trimEXT(); }); </script> Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message Contact Customer Care - Learn CSS - Buy me a coffee (thank you!) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment