Advanced search  

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]

Pages: [1]   Go Down

Author Topic: File size stored in database after using file_replace plugin  (Read 5925 times)

0 Members and 1 Guest are viewing this topic.

Niecher

  • LocalSupporter
  • Coppermine frequent poster
  • ***
  • Country: es
  • Offline Offline
  • Gender: Male
  • Posts: 191
File size stored in database after using file_replace plugin
« on: February 21, 2013, 01:07:43 pm »

The plugin "replace" all it does is replace the image, but does not change the information dimensions and file size.

You must do this manually in administrative tools.

Then you update everything (full-sized, resized and thumbs) for that album, as there is no option to update a single image.

Possibly, the intermediate image is not updated because it does not exist, since it was never established at the time of upload. Perhaps it may be that is created at this time to update everything (no I can assure you, you should try it).

Likewise, this plugin does not change file extensions if the new file has another extension, even if the same image.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: File size stored in database after using file_replace plugin
« Reply #1 on: February 21, 2013, 01:16:30 pm »

Niecher, do you talk about the file_replacer plugin? It actually updates the picture dimensions and file size in the database.
Logged

Niecher

  • LocalSupporter
  • Coppermine frequent poster
  • ***
  • Country: es
  • Offline Offline
  • Gender: Male
  • Posts: 191
Re: File size stored in database after using file_replace plugin
« Reply #2 on: February 21, 2013, 01:44:28 pm »

I must rectify, because I just did a test

The dimensions are changed, but the file size is not. Then you need to use the administrative tools to change the file size in the database.

At least this happens to me and I am using the version (file_replacer): v1.6
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: File size stored in database after using file_replace plugin
« Reply #3 on: February 21, 2013, 01:52:26 pm »

The dimensions are changed, but the file size is not.
Strange, as the code tells something different:
Code: [Select]
                $image_filesize = filesize($image);
                $total_filesize = is_image($filename) ? ($image_filesize + (file_exists($normal) ? filesize($normal) : 0) + filesize($thumb)) : ($image_filesize);
   
                cpg_db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET filesize = '$image_filesize', total_filesize = '$total_filesize', pwidth = '$width', pheight = '$height' WHERE pid = '$pid' LIMIT 1");
Logged

Niecher

  • LocalSupporter
  • Coppermine frequent poster
  • ***
  • Country: es
  • Offline Offline
  • Gender: Male
  • Posts: 191
Re: File size stored in database after using file_replace plugin
« Reply #4 on: February 21, 2013, 02:20:38 pm »

Yes, I see the code in the file codebase.php

But if I replace a file with another file smaller or larger and run in admin tools > reload file dimensions and size information, is always telling me:

for example:

Total filesize is incorrect
Database: 97,830 bytes
Now: 160 794 bytes

updated

This is what happens in my case.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: File size stored in database after using file_replace plugin
« Reply #5 on: February 21, 2013, 02:42:28 pm »

The only difference in the admin tools and plugin code is, that the plugin checks is the current file is an image. Can you please post some more detailed information, or even attach an "old" and "new" test file where the issue occurs in your gallery?

I think I'll split the discussion regarding the plugin later.
Logged

Niecher

  • LocalSupporter
  • Coppermine frequent poster
  • ***
  • Country: es
  • Offline Offline
  • Gender: Male
  • Posts: 191
Re: File size stored in database after using file_replace plugin
« Reply #6 on: February 21, 2013, 03:18:52 pm »

I have thought that if the plugin behaves the same way on nickelas gallery

and as he said he had upload a new file using the plugin replace

Ok, let me know if you need any info. The link is working at the moment because I downloaded the fullsize and uploaded it again using the replace plugin (so fullsize not secured yet). Thought that might cause CPG to start using the normal but it did not. I think a thumbnail was generated but not the normal picture.

and this new file is the original fullsize and larger than the previous file exists, then, for this reason I think he should update the file size in the database

using admin tools > reload file dimensions and size information

and thereupon to do this in admin tools > Update thumbs and / or resized photos > Everything: full-sized, resized and thumbs

and possibly all pictures are regenerated again, including intermediate image

or perhaps the intermediate image is not regenerated, because, was never established at the time of the upload.

This is something he should try and tell us all.

Sorry for the English, but I use google.
Logged

phill104

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4860
    • Windsurf.me
Re: File size stored in database after using file_replace plugin
« Reply #7 on: February 21, 2013, 03:38:37 pm »

or perhaps the intermediate image is not regenerated, because, was never established at the time of the upload.

It would not be regenerated if the original image size it smaller than the settings applied for the intermediate image.
Logged
It is a mistake to think you can solve any major problems just with potatoes.

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: File size stored in database after using file_replace plugin
« Reply #8 on: February 21, 2013, 03:39:12 pm »

Niecher, if the file_replacer plugin doesn't work as expected, fine. But it doesn't matter which value is stored for the file size in the database, as it's not used to determine if an intermediate-sized picture needs to be created or displayed. The plugin also doesn't care if there has already been an intermediate-sized picture, as it always creates it (if needed) while overwriting any prior version. There's no check for already existing files.

Regarding the plugin, please
post some more detailed information, or even attach an "old" and "new" test file where the issue occurs in your gallery
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Logged

Niecher

  • LocalSupporter
  • Coppermine frequent poster
  • ***
  • Country: es
  • Offline Offline
  • Gender: Male
  • Posts: 191
Re: File size stored in database after using file_replace plugin
« Reply #10 on: February 21, 2013, 04:55:12 pm »

I tried the plugin replace with different images, then:

The gallery generates the intermediate image properly or does not generate the intermediate image, as we all know, if the full size image is smaller than the intermediate size image.

Well, it does not replace the 'file_replacer plugin' is:

Filename
File Extension
File size in the database.

To update the file size in the database is necessary to do so in admin tools .

As I said before, for example:

Total filesize is incorrect
Database: 97.830 bytes
Now: 160 794 bytes

updated

Regarding the plugin, please
post some more detailed information, or even attach an "old" and "new" test file where the issue occurs in your gallery

All files are OK, except the replaced file. See the attachment.
Logged

phill104

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4860
    • Windsurf.me
Re: File size stored in database after using file_replace plugin
« Reply #11 on: February 21, 2013, 04:56:41 pm »

Has the jpg quality level changed?
Logged
It is a mistake to think you can solve any major problems just with potatoes.

Niecher

  • LocalSupporter
  • Coppermine frequent poster
  • ***
  • Country: es
  • Offline Offline
  • Gender: Male
  • Posts: 191
Re: File size stored in database after using file_replace plugin
« Reply #12 on: February 21, 2013, 05:09:01 pm »

is the same for JPG and PNG files, the file size in the database is always updated in admin tools, and not by the plugin.

The quality of JPEG files is set to 100%
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: File size stored in database after using file_replace plugin
« Reply #13 on: February 22, 2013, 11:39:18 am »

Open codebase.php, find
Code: [Select]
$total_filesize = is_image($filename) ? ($image_filesize + (file_exists($normal) ? filesize($normal) : 0) + filesize($thumb)) : ($image_filesize);and replace with
Code: [Select]
$total_filesize = is_image($row['filename']) ? ($image_filesize + (file_exists($normal) ? filesize($normal) : 0) + filesize($thumb)) : ($image_filesize);
Please report if it works as expected.
Logged

Niecher

  • LocalSupporter
  • Coppermine frequent poster
  • ***
  • Country: es
  • Offline Offline
  • Gender: Male
  • Posts: 191
Re: Re: File size stored in database after using file_replace plugin
« Reply #14 on: February 22, 2013, 02:36:41 pm »

Yes André, this new code works perfectly.

Thank you very much.

Has the jpg quality level changed?

Thank you too Phil, after your question, I replaced the jpeg quality level from 100 to 80 (default)

Do not see the difference in quality.

I update thumbsnails and intermediate images.

Obviously it reduced the size of these images, and the PageSpeed ​​increased from 77 to 92.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: File size stored in database after using file_replace plugin
« Reply #15 on: February 22, 2013, 02:38:19 pm »

Marking as solved. Will commit the change soon and also maybe release a new plugin version.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: Re: File size stored in database after using file_replace plugin
« Reply #16 on: April 10, 2013, 02:35:38 pm »

You can download the new plugin version 1.7 here.
Logged
Pages: [1]   Go Up
 

Page created in 0.036 seconds with 20 queries.