การกำหนดค่าผลการค้นหา
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เช่นเดียวกับการปรับแต่งช่องค้นหา คุณสามารถใส่ตัวเลือกอื่นๆ ในองค์ประกอบของผลการค้นหาได้
ตัวอย่างเช่น หากต้องการเปลี่ยนเครื่องมือค้นหาของเราจากผลการค้นหาแบบเว็บ
หรือสำหรับรูปภาพ เราสามารถใช้แอตทริบิวต์ defaultToImageSearch
ได้
ก่อนอื่นคุณต้องเปิดใช้การค้นหารูปภาพในแผงควบคุมสำหรับเครื่องมือค้นหา ในส่วนการตั้งค่า ในแท็บพื้นฐาน ให้คลิกตัวเลือกการค้นหารูปภาพลงใน "เปิด" ตำแหน่ง หลังจากนั้น ให้เพิ่มแอตทริบิวต์ defaultToImageSearch
ลงในองค์ประกอบ <div class="gcse-searchresults"></div>
ในเว็บไซต์
<!-- ใส่รหัส Programmable Search Engine ของคุณเองที่นี่ -->
<script async src="https://cse.google.com/cse.js?cx=017643444788069204610:4gvhea_mvga"></script>
<!-- ลองเปลี่ยนค่าแอตทริบิวต์เป็น "true" หรือ "เท็จ" -->
<div class="gcse-searchbox"></div>
<div class="gcse-searchresults" data-defaultToImageSearch="true"></div>
ตอนนี้ เมื่อคุณค้นหาสิ่งต่างๆ แท็บค้นหารูปภาพจะแสดงเป็นค่าเริ่มต้น
มีตัวเลือกอีกมากมาย คุณสามารถอ่านเกี่ยวกับตัวเลือกการปรับแต่งผลการค้นหาอื่นๆ ได้ในส่วน Programmable Search Element Control API
ถัดไป...
ไปที่ขั้นตอนถัดไป
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-25 UTC
[null,null,["อัปเดตล่าสุด 2025-07-25 UTC"],[[["\u003cp\u003eThe search results element can be customized with additional options, such as switching to image-based results using the \u003ccode\u003edefaultToImageSearch\u003c/code\u003e attribute.\u003c/p\u003e\n"],["\u003cp\u003eTo enable image search, you need to activate it in the Control Panel for your search engine and then add the \u003ccode\u003edefaultToImageSearch\u003c/code\u003e attribute to the search results div element.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003edefaultToImageSearch\u003c/code\u003e attribute, when set to "true", makes the image search tab the default view for search results.\u003c/p\u003e\n"],["\u003cp\u003eFurther customization options for search results can be found in the Programmable Search Element Control API documentation.\u003c/p\u003e\n"]]],[],null,["# Customizing Search Results\n\nIn a similar way to customizing search box, you can add additional options to the search results element.\n\nFor example, in order to change our search engine from webresults-based\nto image-based, we can utilize the `defaultToImageSearch` attribute.\n\nFirst of all, you need to enable Image Search in the [Control Panel](https://programmablesearchengine.google.com) for your search engine. In the **Setup** section, in **Basics** tab, click the **Image search** option into the \"on\" position. After that, add the `defaultToImageSearch` attribute to the `\u003cdiv class=\"gcse-searchresults\"\u003e\u003c/div\u003e` element on your website. \n\\\u003c!-- Insert your own Programmable Search Engine ID here --\\\u003e \\\u003cscript async src=\"https://cse.google.com/cse.js?cx=017643444788069204610:4gvhea_mvga\"\\\u003e\\\u003c/script\\\u003e \\\u003c!-- Try switching the attribute value to \"true\" or \"false\" --\\\u003e \n\n \u003cdiv class=\"gcse-searchbox\"\u003e\u003c/div\u003e\n \u003cdiv class=\"gcse-searchresults\" data-defaultToImageSearch=\"true\"\u003e\u003c/div\u003e\n\nNow, when you search for something, the image search tab is showing as a default.\n\nThere are many more options available. You can read about other search results customization options in [Programmable Search Element Control API](/custom-search/docs/element#supported_attributes) section.\n\nNext...\n-------\n\nContinue to [Next steps](/custom-search/docs/tutorial/nextsteps)."]]