coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 cpmFetch by vuud => Topic started by: PaperMakeiT on December 02, 2007, 11:30:39 PM

Title: Issues filtering images by extension
Post by: PaperMakeiT on December 02, 2007, 11:30:39 PM
Hi all,
I introduce myself: I am the vile administrator of a site dedicated to Paper Crafts and our Members upload images on the gallery that are shown then on a SMF forum. I implemented the cpmFetch and now on the forum we can see the last added images and also some random chosen.

I don't find the way to make the filter work: among images we see also .pdf and .zip files even if the filter is set to .jpg. I would like to filter only .jpg, .gif, .png but I tried the array uselessly. Probably I omit something. I tried to look at this forum but I didn't find anything to solve my problem.

The gallery: www.gallery.papermakeit.com

The forum: www.paperworlds.papermakeit.com

The cpmFetch directory is in www.gallery.papermakeit.com/cpmfetch

I uploaded Coppermine to last release and downloaded cpmFetch two days ago, so they should be updated.

One of the codes I used was:

<table width="100%">
<tr><td>
<div class="tborder" style="margin-top: 5px;">
      <div class="catbg" style="padding: 5px 5px 5px 10px;" align="center">
  <a href="http://gallery.papermakeit.com/index.php" target=blank>Paper Worlds Gallery - Latest Added</a>
     
                  </div>
                  <table width="100%" class="tborder2" align="center">
                  <tr align="center"><td align="center">
                  ';
                                        include "../gallery/cpmfetch/cpmfetch.php";
                                        $objCpm = new cpm("../gallery/cpmfetch/cpmfetch_config.php");
                                        $objCpm->cpm_setFilter($filter=".jpg");
                                        $objCpm->cpm_viewLastAddedMedia(1,6,$filter);
                                   echo '
                                    </td></tr></table>
                                   
                                   
</div>
</td>
<td width=250px>
<div class="tborder" style="margin-top: 5px;">
      <div class="catbg" style="padding: 5px 5px 5px 10px;" align="center">
  <a href="http://gallery.papermakeit.com/index.php" target=blank>Random Images</a>
     
                  </div>
                  <table width="100%" class="tborder2" align="center">
                  <tr align="center"><td align="center">
                  ';
                                       
                                        $objCpm->cpm_viewRandomMedia(1,2,$filter);
                                        $objCpm->cpm_close();
                  echo '
                  </td></tr>
                  </table>

</td>
</tr>
</table>



And what is exactly the code to filter more than one extensions? Something like this:

<table width="100%">
<tr><td>
<div class="tborder" style="margin-top: 5px;">
      <div class="catbg" style="padding: 5px 5px 5px 10px;" align="center">
  <a href="http://gallery.papermakeit.com/index.php" target=blank>Paper Worlds Gallery - Latest Added</a>
     
                  </div>
                  <table width="100%" class="tborder2" align="center">
                  <tr align="center"><td align="center">
                  ';
                                        include "../gallery/cpmfetch/cpmfetch.php";
                                        $objCpm = new cpm("../gallery/cpmfetch/cpmfetch_config.php");
                                        $objCpm->cpm_setFilter($filter=array(".jpg",".gif",".png");
                                        $objCpm->cpm_viewLastAddedMedia(1,6,$filter);
                                   echo '
                                    </td></tr></table>
                                   
                                   
</div>
</td>
<td width=250px>
<div class="tborder" style="margin-top: 5px;">
      <div class="catbg" style="padding: 5px 5px 5px 10px;" align="center">
  <a href="http://gallery.papermakeit.com/index.php" target=blank>Random Images</a>
     
                  </div>
                  <table width="100%" class="tborder2" align="center">
                  <tr align="center"><td align="center">
                  ';
                                       
                                        $objCpm->cpm_viewRandomMedia(1,2,$filter);
                                        $objCpm->cpm_close();
                  echo '
                  </td></tr>
                  </table>

</td>
</tr>
</table>


Thank you very much for your kind help.

Claudio
Title: Re: Issues filtering images by extension
Post by: PaperMakeiT on December 04, 2007, 12:48:43 PM
I am trying several combination of the word "filter" within the lines but useless.

Now I tried to modify the cpmfetch_config.php adding this setting:



// Filters out file types to display or not-display
    $config_overrides['cfFileTypeFilter'] = 'jpg';


But everything is as usual: the images shown are of every kind.

Claudio
Title: Re: Issues filtering images by extension
Post by: PaperMakeiT on December 05, 2007, 10:41:56 AM
Looking at the forum log of SMF I found this error:

8: Undefined property: AND ( p.filename like '%.jpg' OR p.filename like '%.JPG' OR
File: /home/papermak/public_html/gallery/cpmfetch/cpmfetch_dao.php


Does someone know something about it?

Claudio
Title: Re: Issues filtering images by extension
Post by: PaperMakeiT on December 05, 2007, 02:50:09 PM
Well, now the error doesn't appear anymore. Even if the images aren't still filtered. The hunt continues...
Claudio
Title: Re: Issues filtering images by extension
Post by: PaperMakeiT on December 05, 2007, 06:17:46 PM
Added the array within cpmfetch_dao.php:

function cpm_setFilter($filter=array(".jpg",".png",".gif",".bmp",".jpeg")) {

and no news.

To be continued, Claudio
Title: Re: Issues filtering images by extension
Post by: PaperMakeiT on December 06, 2007, 10:04:23 AM
ok, I reached a solution in this way:

1) in your html page add the following lines in order to show 2 random images in one row from category n.1; the images are filtered as indicated into array ans so documents (.doc, .pdf, .zip, etc.) are not shown:


                                 <td>
                                        ';
                                        include_once "../gallery/cpmfetch/cpmfetch.php";
                                        $objCpm = new cpm("../gallery/cpmfetch/cpmfetch_config.php");
                                        $objCpm->cpm_setFilter($filter=array(".jpg",".jpeg",".gif",".png",".bmp"));
                                        $objCpm->cpm_viewRandomMediaFrom("cat=1",1,2);
                                        echo '
                                 </td>


2) added a line of code in cpmfetch_dao.php. But I don't know if this is allowed by the author, so I omitted to write it.

Thank you all for the support.

Claudio
Title: Re: Issues filtering images by extension
Post by: vuud on December 11, 2007, 03:25:13 AM
Quote from: PaperMakeiT on December 06, 2007, 10:04:23 AM
2) added a line of code in cpmfetch_dao.php. But I don't know if this is allowed by the author, so I omitted to write it.

Sure its allowed.  Heck, send it to me - if it fixes a problem I will include it.

Time is short now-a-days regrettably.

Time for a new release I think...
Title: Re: Issues filtering images by extension
Post by: VISTREL on March 11, 2008, 06:05:38 PM
I have the same problem.

My verison: copperminefetch-2.0.0

This is the code I'm trying to use but it still displays mp3s.

$objCpm->cpm_setFilter($filter=array(".jpg",".jpeg",".gif",".png",".bmp"));
$objCpm->cpm_viewLastAddedMediaFrom($id,$rows, $column, $options,$filter);


Somebody please help me. I need to get my site online very soon.
Title: Re: Issues filtering images by extension
Post by: radmofo on April 18, 2008, 08:25:17 PM
Sure would be nice if people would post the solutions to these things!
Title: Re: Issues filtering images by extension
Post by: capecodgal on May 09, 2008, 02:08:46 PM
I have only ever gotten it to work with one filter; I tried multiple and it never worked so I just assumed it could only handle one. Your code looks good to me... here is the sample I used:


<?php
 
require_once "./cpg/cpmfetch/cpmfetch.php";
 
$objCpm = new cpm("./cpg/cpmfetch/cpmfetch_config.php");
$objCpm->cpm_setfilter($filter ".jpg");
$options = array('windowtarget' => '_blank',"imagewidth"=>"100","subtitle" => "<center> {{pHits}} Views</center>");
$objCpm->cpm_viewLastAddedMedia(2,3,$options,$filter);
 
$objCpm->cpm_close();
?>



That works for me and only pulls JPG so I don't display the ZIP on my videos and only the JPG thumbs; I think i am running 2.0.0 with the latest CPG
Title: Re: Issues filtering images by extension
Post by: lotoazul on June 15, 2008, 08:16:29 AM
Quote from: PaperMakeiT on December 06, 2007, 10:04:23 AM
ok, I reached a solution in this way:

1) in your html page add the following lines in order to show 2 random images in one row from category n.1; the images are filtered as indicated into array ans so documents (.doc, .pdf, .zip, etc.) are not shown:

2) added a line of code in cpmfetch_dao.php. But I don't know if this is allowed by the author, so I omitted to write it.

Thank you all for the support.

Claudio


did claudio's solution work after all? 'cause i would love to be able to do that, but i wouldn't know how to even start tinkering with cpmfetch_dao.php. any chance we can have that line of code?