I have made a site in HTML (using divs not tables and lightbox.js) that is selling photography. Is there a way to add an image search function in Java or PHP without making a database? If so, please include details on what formats/libraries I should use. I'm a new graduate and I've been searching the net and stackoverflow for two days and find bits and pieces but nothing that takes me from start to finish. Thank You
Asked
Active
Viewed 520 times
0
-
What exactly do you mean by an "image search function?" Why the "without making a database" requirement? – Matt Ball Sep 05 '13 at 18:40
-
1Yes, search through a directory containing files. *"please include details on what formats/libraries I should use."* **You** need to make an attempt to do it yourself then come back here when you actually have a problem. The only complete answer to this question would be nearly a full working solution, but we don't even know where or how you're storing the images, how many there are, how they're organized, how you want to search for them, etc – Kevin B Sep 05 '13 at 18:40
-
There are presently over two hundred images right now and more to be added, separated into galleries (separate pages) such as nature, people, architecture and abstracts, but they are wanting a search that would be able to search for example, "blue" or "water". I'm storing the images in a image folder with sub folders per gallery. I would make an attempt except I have no idea where to start. I don't need a full working solution, just an idea of where to start please, or a no it's not possible, I'm the only web designer with in a hundred miles so I can't just go ask my boss or peers. – Brooke Hale Sep 05 '13 at 19:04
-
I didn't want a database just due to the time requirement and not sure how to add it to what is already coded without starting over. A directory search sounds like what I'm looking for, but then will it search the keywords added to the images metadata? – Brooke Hale Sep 05 '13 at 19:10
1 Answers
0
I don't know if this is something like what you are looking for, but using JQuery you can make a simple "search" using autocomplete.
First: Make your images have ID's equivalent to the "name" you want to be searched. Something similar to this:
<div id="img1">
<img id="Image1" alt="Image 1" />
</div>
<div id="img2">
<img id="Image2" alt="Image 2" />
</div>
<div id="img3">
<img id="Image3" alt="Image 3" />
</div>
Second: You can then get all of your "img" tag IDs into an array and make a JQuery UI (http://jqueryui.com/autocomplete/) autocomplete input field like below:
HTML
<input id="autocomplete" />
JQuery
var images = new Array();
$("img").each(function() {
images.push($(this).attr("id"));
});
$("#autocomplete").autocomplete({
source: images
});
Now that you have your image IDs (names) in an autocomplete/search field, you can add a button that "searches" on the selected autocomplete image ID and display only that image.
HTML
<button id="search">View Image</button>
JQuery
$("#search").click(function() {
var field = $("#autocomplete").val();
$("img").hide(); //Hide all images
$("#"+field).show();
});
I hope this helps, even if it isn't exactly what you were looking for. A full demo is here: JSFiddle

Tricky12
- 6,752
- 1
- 27
- 35