Issues filtering images by extension Issues filtering images by extension
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Issues filtering images by extension

Started by PaperMakeiT, December 02, 2007, 11:30:39 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

PaperMakeiT

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

PaperMakeiT

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

PaperMakeiT

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

PaperMakeiT

Well, now the error doesn't appear anymore. Even if the images aren't still filtered. The hunt continues...
Claudio

PaperMakeiT

Added the array within cpmfetch_dao.php:

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

and no news.

To be continued, Claudio

PaperMakeiT

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

vuud

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...
Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

VISTREL

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.

radmofo

Sure would be nice if people would post the solutions to these things!
Please give me some negative Karma. :)

capecodgal

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

lotoazul

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?