spurds Posted February 15, 2023 Share Posted February 15, 2023 Probably a very simple question/fix but when I search on my website using the search block, the results page shows the name of the jpg file associated with the item. Is there a way to stop this from happening? I would of course rather the description of the product (or some of it) to show instead. Thanks! Link to comment
tuanphan Posted February 21, 2023 Share Posted February 21, 2023 Hi, You can add this code to Code Injection > Footer to remove jpg name <!-- 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