File size stored in database after using file_replace plugin File size stored in database after using file_replace plugin
 

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

Main Menu

File size stored in database after using file_replace plugin

Started by Niecher, February 21, 2013, 01:07:43 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Niecher

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.

Αndré

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

Niecher

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

Αndré

Quote from: Niecher on February 21, 2013, 01:44:28 PM
The dimensions are changed, but the file size is not.
Strange, as the code tells something different:
                $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");

Niecher

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.

Αndré

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.

Niecher

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

Quote from: nickelas on February 21, 2013, 12:28:42 PM
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.

phill104

Quote from: Niecher on February 21, 2013, 03:18:52 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.
It is a mistake to think you can solve any major problems just with potatoes.

Αndré

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
Quote from: Αndré on February 21, 2013, 02:42:28 PM
post some more detailed information, or even attach an "old" and "new" test file where the issue occurs in your gallery


Niecher

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

Quote from: Αndré on February 21, 2013, 03:39:12 PM
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.

phill104

It is a mistake to think you can solve any major problems just with potatoes.

Niecher

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%

Αndré

Open codebase.php, find
$total_filesize = is_image($filename) ? ($image_filesize + (file_exists($normal) ? filesize($normal) : 0) + filesize($thumb)) : ($image_filesize);
and replace with
$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.

Niecher

Yes André, this new code works perfectly.

Thank you very much.

Quote from: Phill Luckhurst on February 21, 2013, 04:56:41 PM
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.

Αndré

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

Αndré