d-kar Posted October 2, 2023 Posted October 2, 2023 I've got a bit of a catch-22 here. Client wants to remove asset image extensions (pear.jpg etc) from appearing in dedicated search - client also does not want the assets renamed to anything other than what the item is. Is there any way I can block the text or remove the entire description from the search? I'm pulling my hair out here.
tuanphan Posted October 6, 2023 Posted October 6, 2023 Try this code to Website Tools (under Not Linked) > Code Injection > Footer <!-- Remove jpg in search page --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.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!)
d-kar Posted October 6, 2023 Author Posted October 6, 2023 No dice, unfortunately. I appreciate the response, though.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment