forum.coppermine-gallery.net

Support => cpg1.5.x Support => cpg1.5 miscellaneous => Topic started by: Marcovw on May 02, 2012, 04:34:46 pm

Title: Searching by size
Post by: Marcovw on May 02, 2012, 04:34:46 pm
Hello there.

I've been looking for it but can't find anything about it. Is it possible to make it so that people can search for images based on file size or image size?

File size = ## MB search
Image size = Height x Width search

Thanks in advance,
Marco
Title: Re: Searching by size
Post by: Αndré on May 02, 2012, 07:12:24 pm
Do you want to extend the current search form or do you want to have a separate search form?
Title: Re: Searching by size
Post by: Marcovw on May 04, 2012, 08:40:57 am
I wish to extend it, thus adding it at the list of the default searches.
Title: Re: Searching by size
Post by: Αndré on May 04, 2012, 10:22:06 am
Should it be an exact or min/max search? Do you already have some ideas about the front-end design?
Title: Re: Re: Searching by size
Post by: Marcovw on May 08, 2012, 09:10:25 am
Should it be an exact or min/max search? Do you already have some ideas about the front-end design?

I just want to keep it simple. Add fields in the "search" area.. I made a screenshot of how I want, most text is in Dutch, but the part I want will be in english. When I have the code to add the function I'm pretty sure I can translate it ^_^

http://postimage.org/image/f5ysgee73/ (http://postimage.org/image/f5ysgee73/)

Awesome M$Paint skills are awesome
Title: Re: Searching by size
Post by: Αndré on May 08, 2012, 11:50:41 am
I still don't get how your file size search is supposed to work. Will the user enter something like 1485395 and then all images with that file size (in Bytes) will be displayed?

Attached is your hot-linked screenshot.
Title: Re: Searching by size
Post by: Marcovw on May 15, 2012, 09:32:46 am
Oh, you wanted to know that. I missunderstood you, my apologies.

Yes, for the file size the user just enter te file size (in Bytes). I know it's pretty odd, but they want it like that.
Title: Re: Searching by size
Post by: Αndré on May 15, 2012, 11:42:07 am
Open thumbnails.php, find
Code: [Select]
$allowed = array('title', 'caption', 'keywords', 'filename', 'pic_raw_ip', 'pic_hdr_ip', 'user1', 'user2', 'user3', 'user4', 'type', 'owner_name');or
Code: [Select]
$allowed = array('title', 'caption', 'keywords', 'filename', 'pic_raw_ip', 'pic_hdr_ip', 'user1', 'user2', 'user3', 'user4', 'type', 'owner_name', 'newer_than', 'older_than');(depending on which version you currently use)
and replace with
Code: [Select]
$allowed = array('title', 'caption', 'keywords', 'filename', 'pic_raw_ip', 'pic_hdr_ip', 'user1', 'user2', 'user3', 'user4', 'type', 'owner_name', 'newer_than', 'older_than', 'filesize', 'pwidth', 'pheight');

open search.php, find
Code: [Select]
$owner_name
$customs
$ip
and above, add
Code: [Select]
                                        <tr>
                                                <td align="right" colspan="2">File size <input type="text" name="filesize" size="6" class="textinput" /> Byte</td>
                                        </tr>
                                        <tr>
                                                <td align="right" colspan="2">Picture width <input type="text" name="pwidth" size="6" class="textinput" /> Pixel</td>
                                        </tr>
                                        <tr>
                                                <td align="right" colspan="2">Picture height <input type="text" name="pheight" size="6" class="textinput" /> Pixel</td>
                                        </tr>


open include/search.inc.php, find
Code: [Select]
$sql .=  " AND approved = 'YES' $FORBIDDEN_SET";and above, add
Code: [Select]
        $sql .= Inspekt::isInt($USER['search']['params']['filesize']) ? ' AND ( filesize = '.$USER['search']['params']['filesize'].')' : '';
        $sql .= Inspekt::isInt($USER['search']['params']['pwidth']) ? ' AND ( pwidth = '.$USER['search']['params']['pwidth'].')' : '';
        $sql .= Inspekt::isInt($USER['search']['params']['pheight']) ? ' AND ( pheight = '.$USER['search']['params']['pheight'].')' : '';
Title: Re: Searching by size
Post by: Marcovw on June 05, 2012, 03:45:35 pm
Sorry I did not reply earlier, didn't had time to focus on Coppermine because of another project.

Anyhow, the searching by size works, but with a small flaw. I tested it, by trying to search by different sizes, but didnt get any hits, until I added a letter in the search box wich was also present in a image, then I get some results by size.

What I want is just to insert the values of hight, width or filesize, withouth having to input something in the search box.
Title: Re: Searching by size
Post by: Αndré on June 05, 2012, 03:51:27 pm
Open search.php, find
Code: [Select]
<input type="text" style="width: 80%" name="search" maxlength="255" value="" class="textinput" />and replace with
Code: [Select]
<input type="text" style="width: 80%" name="search" maxlength="255" value="*" class="textinput" />
Title: Re: Searching by size
Post by: Marcovw on June 05, 2012, 04:29:35 pm
Awesome, if I'd actually spend time thinking about, I could've thought of that "*" myself.

Who da man?

You da man!
Title: Re: Searching by size
Post by: Αndré on June 05, 2012, 04:55:40 pm
Please
tag your answer as "solved" by clicking on the "Topic Solved" button on the bar at the left hand side at the bottom of your thread.