Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: Issues filtering images by extension  (Read 10516 times)

0 Members and 1 Guest are viewing this topic.

PaperMakeiT

  • Coppermine newbie
  • Offline Offline
  • Posts: 6
Issues filtering images by extension
« 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:

Code: [Select]
<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:

Code: [Select]
<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
Logged

PaperMakeiT

  • Coppermine newbie
  • Offline Offline
  • Posts: 6
Re: Issues filtering images by extension
« Reply #1 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:


Code: [Select]
// 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
Logged

PaperMakeiT

  • Coppermine newbie
  • Offline Offline
  • Posts: 6
Re: Issues filtering images by extension
« Reply #2 on: December 05, 2007, 10:41:56 am »

Looking at the forum log of SMF I found this error:

Code: [Select]
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
Logged

PaperMakeiT

  • Coppermine newbie
  • Offline Offline
  • Posts: 6
Re: Issues filtering images by extension
« Reply #3 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
Logged

PaperMakeiT

  • Coppermine newbie
  • Offline Offline
  • Posts: 6
Re: Issues filtering images by extension
« Reply #4 on: December 05, 2007, 06:17:46 pm »

Added the array within cpmfetch_dao.php:

Code: [Select]
function cpm_setFilter($filter=array(".jpg",".png",".gif",".bmp",".jpeg")) {
and no news.

To be continued, Claudio
Logged

PaperMakeiT

  • Coppermine newbie
  • Offline Offline
  • Posts: 6
Re: Issues filtering images by extension
« Reply #5 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:

Code: [Select]
                                 <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
Logged

vuud

  • Moderator
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1803
  • [cpmfetch.fistfullofcode.com]
    • Fist Full Of Code
Re: Issues filtering images by extension
« Reply #6 on: December 11, 2007, 03:25:13 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...
Logged
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

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
Re: Issues filtering images by extension
« Reply #7 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.

Code: [Select]
$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.
Logged

radmofo

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 31
Re: Issues filtering images by extension
« Reply #8 on: April 18, 2008, 08:25:17 pm »

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

capecodgal

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 123
Re: Issues filtering images by extension
« Reply #9 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:

Code: [Select]
<?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
Logged

lotoazul

  • Coppermine newbie
  • Offline Offline
  • Posts: 5
Re: Issues filtering images by extension
« Reply #10 on: June 15, 2008, 08:16:29 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?
Logged
Pages: [1]   Go Up
 

Page created in 0.028 seconds with 20 queries.