News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Automatic Attachment Rotation (and Resize)

Started by dougiefresh, March 04, 2016, 07:34:59 PM

Previous topic - Next topic

GL700Wing

Uploaded v5.10 - October 2, 2020
o Added option to enable/disable mod via an admin setting.
o Added option to configure PHP memory limit specifically for this mod. (Note: The Image Processing Memory Limit mod is no loner required).
o Added option to configure different JPEG quality and max width/height for specific membergroups (eg, admins, moderators, other regular groups and/or post count based groups).
o Updated and streamlined code for image rotation and resizing processes.
o Removed support for SMF 2.1 (all versions).
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

forumovod

Community of forum owners (сообщество владельцев форумов на любых движках) https://forumovod.ru

GL700Wing

Uploaded v5.11 - October 2, 2020
o Minor bug fix to V5.10
o Improved integration with Post and PM Inline Attachments mod.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

TourFL

Hello,

I installed the latest versions I still have the problem of unknown thumb_hash/thumb_name/thumb_folder in my error logs
I compared my local display.php file with the official SMF 2.0.17 file and I don't see anything which could interfir with that code, and that line generating the errors has been add by this module.
The module is perfectly installed with no error/conflict

So I checked my database. I see the attachement table has the id_thumb column, but the thumb_hash/thumb_name/thumb_folder are not present. Is this the problem? What are they meant to be created from? Shall I add those columns manually?

Thanks
If you like Fiat 500 and derived models, the SMF forum I'm helping with: www.500-126.com

GL700Wing

Quote from: TourFL on October 20, 2020, 05:23:37 AM
I installed the latest versions I still have the problem of unknown thumb_hash/thumb_name/thumb_folder in my error logs
I compared my local display.php file with the official SMF 2.0.17 file and I don't see anything which could interfir with that code, and that line generating the errors has been add by this module.
The module is perfectly installed with no error/conflict

So I checked my database. I see the attachement table has the id_thumb column, but the thumb_hash/thumb_name/thumb_folder are not present. Is this the problem? What are they meant to be created from? Shall I add those columns manually?
There are no separate columns in the database for thumb_hash, thumb_name or thumb_folder - these values are derived from the file_hash, filename and id_folder columns respectively.

I am not able to reproduce the issue you've reported when this mod is installed on a new SMF 2.0.17 forum and from what you've described it seems that this mod may not have uninstalled fully/correctly at some stage in the past - please attach a copy of your ./Sources/Display.php file.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

TourFL

Thanks for your help!
Here is the display.php file.

Today I tried a a full verification of the attached files and avatar, using the built-in SMF tool. It corrected some errors, including some attachements with bad parent (?) or wrong size files. We'll see if it helps.
If you like Fiat 500 and derived models, the SMF forum I'm helping with: www.500-126.com

GL700Wing

Quote from: TourFL on October 20, 2020, 07:20:27 AM
Thanks for your help!
Here is the display.php file.
I can't find any issues in your Display.php file in relation to this mod - I can see that you also have the @mention members, Last Post From Previous Page and Topic Solved mods installed but even after I installed those mods with this mod I still can't reproduce the issue you reported.

I did, however, notice that you have installed the Last Post From Previous Page mod twice as the code from two different versions is in Display.php - from lines 1201-1206 (older version) and from lines 1207-1216 (more recent version).  I'd suggest that you uninstall the Last Post From Previous Page mod, cleanup Display.php to make sure there is no code from earlier versions left and then install the latest version.

QuoteToday I tried a a full verification of the attached files and avatar, using the built-in SMF tool. It corrected some errors, including some attachements with bad parent (?) or wrong size files. We'll see if it helps.
Given there are no issues in your Display.php file I was going to suggest that you run "Administration Center » Attachments and Avatars » File Maintenance" to resolve any database/file system errors.



Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

TourFL

Thanks for analysis, I cleaned the old code from "Last Post From Previous Page"!

This morning I got 83 errors, so the File Maintenance didn't help  :'(

I saw all the errors are coming from:
- search: .../index.php?action=search2;params=XXX
- Showing user posts: Appliquer le filtre: .../index.php?action=profile;area=showposts;u=999
- Posting: .../index.php?action=post;topic=10023.15;last_msg=218212

I could reproduce it my self, if I do a reply on a subject including photos, the reply page will show the last 15 posts. There was 3 images within those messages, I got 9 errors (3 per image)
Same if I show user posts or perform a search, if images are showing in the results, I get 3 errors per image.

However, no problem when I read subjects "normaly". I'll investigate the post.php and search.php to see if they can be the source of the problem
If you like Fiat 500 and derived models, the SMF forum I'm helping with: www.500-126.com

TourFL

Can't find anything more :(
I checked post.php, display, subs, post-template, search... found 2-3 mistakes that I corrected, but errors are still here. And from the code search I did, the only references to those are in the display.php file, and introduced by this module.

As mentionned earlier, I pinpointed the cases triggering errors. If I display images by reading messages, it's working fine. But images displayed in seach results, list of user messages, or replying to a post if images are displayed in the last 15 posts showing under the reply box -> 3 errors per image.
Feels like in those cases, the SQL request is not performed before.

I'm no SQL programmer, but I try to understand what's wrong.
In my file, I see the line causing problem is refering to $attachement['thumb_hash']
I found its initialisation:
$attachments = array();
and the SQL request setting the 3 problematic variable just under. Shouldn't be the initialisation of $attachement after the SQL request?
If you like Fiat 500 and derived models, the SMF forum I'm helping with: www.500-126.com

GL700Wing

Quote from: TourFL on October 22, 2020, 09:33:17 AM
Can't find anything more :(
I checked post.php, display, subs, post-template, search... found 2-3 mistakes that I corrected, but errors are still here. And from the code search I did, the only references to those are in the display.php file, and introduced by this module.
It's possible, with multiple mods installed (and even if all the mods install without any errors), to end up with a situation where unexpected errors occur even when these errors never occur when the mods are installed individually. 

Also, the order in which mods are installed (ie, mod A, mod B, mod C, mod D) can result in errors occurring that don't happen when the mods are installed in a different order (ie, mod B, mod D, mod C, mod A).

If you let me know all the mods you've got installed I'll setup a test SMF 2.0.17 forum and install the latest version of each mod to see if I can reproduce the problem (obviously the forum files wont have any modifications you've made but it will be a start).
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

TourFL

Thanks again! My installed mods:

  • Activity Reminder   1.0 
  • Aeva Media   1.2 
  • Age to DOB   1.0 
  • BBCode with style   1.5.1 
  • SMF Search Enhancement Mod   1.8.2 
  • Show Number of Errors at Top of Forum   1.1.2 
  • InLine Attachments   1.2.1 
  • Last Post From Previous Page   1.2 
  • Log Karma Actions   1.1 
  • No Log Certain User Errors   1.0 
  • Register Redirect   1.0 
  • Google Member Map   2.6 
  • Stop Spammer   2.3.9 
  • TinyPortal   1.107 
  • Todays Birthday   1.2 
  • Top 10 Posters and Topic Starters Stats (Today, Week, Month, and Year)   2.6 
  • Topic Solved   1.1.1 
  • Trad Fr de Tinyportal  1.0 beta 5-1 
  • Annoy User   1.2.2 
  • Contact Form   1.1 
  • DisableTemplateEval   1.2 
  • Drafts   2.0.5 
  • Google Analytics Code   1.1 
  • Improved Webmaster Email Settings   1.1 
  • nCode Image Resizer   1.3.1 
  • @mention members   1.1.2 
  • Automatic Attachment Rotation (and Resize)   5.11 
  • Tapatalk SMF 2.0 Plugin   4.5.7 
  • SMF 2.0.17 Update   1.0 
  • Treasury   2.12
I'm not sure all of them still exist  :-\
What I suspect, is problem with In Line Attachement (ILA), but my problem is if I switch to an alternative mod (for example yours), syntaxe of attachement will be different and I would have thousands of message to update in order to have everything working again  :(
If you like Fiat 500 and derived models, the SMF forum I'm helping with: www.500-126.com

TourFL

I did some more tests, and saw that if I de-activate the automatic rotation in the admin panel, I still get errors. So I tend to think that the 3 actions generating errors (reply, search, list user messages) are not going through your updated SQL request.

On my side I replaced the line generating errors in display.php:
Quote$thumb_realname = getAttachmentFilename($attachment['thumb_name'], $attachment['id_thumb'], $attachment['thumb_folder'], false, $attachment['thumb_hash']);
by some simple tests to avoid those errors:
Quoteif (isset ($attachment['thumb_hash']) )
{
   $thumb_realname = getAttachmentFilename($attachment['thumb_name'], $attachment['id_thumb'], $attachment['thumb_folder'], false, $attachment['thumb_hash']);
}
else
{
   $thumb_realname = "";
}

Just a dirty workaround, but in the end it works as before without generating errors!
If you like Fiat 500 and derived models, the SMF forum I'm helping with: www.500-126.com

GL700Wing

Quote from: TourFL on October 23, 2020, 02:35:15 AM

  • InLine Attachments   1.2.1
What I suspect, is problem with In Line Attachement (ILA), but my problem is if I switch to an alternative mod (for example yours), syntaxe of attachement will be different and I would have thousands of message to update in order to have everything working again  :(
I installed ILA 1.2.1 on a test forum, added some inline attachments, uninstalled ILA 1.2.1 and then installed Post and PM Inline Attachments and I can confirm that attachments inserted inline by ILA 1.2.1 are also displayed inline by the Post and PM Inline Attachments mod.

There are a number of settings for the the Post and PM Inline Attachments mod that will determine how inline attachments are displayed - you may need to try changing some of these to get the same inline display effect you have now - or to choose something different.

Finally, make sure you backup all the files updated by these mods before you uninstall/install either of them.

Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Sir Osis of Liver

Installed rotation mod in 2.0.17, it's enabled, no dropmenu in reply editor.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

GL700Wing

Thanks for reporting this issue - just letting you know I'm away on holidays until 9 January and I'll investigate it when I return.

Quote from: Sir Osis of Liver on December 30, 2020, 11:50:09 AM
Installed rotation mod in 2.0.17, it's enabled, no dropmenu in reply editor.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Sir Osis of Liver

Yarf. :(  I'll see if the auto rotation works.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

GL700Wing

#276
Quote from: Sir Osis of Liver on December 30, 2020, 08:49:16 PM
Yarf. :(  I'll see if the auto rotation works.
Haven't had any reports of auto-rotation not working and on all my forums the option to manually rotate images is available when editing/modifying existing posts.
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Sir Osis of Liver

Ok, got it working.  Dropmenu doesn't display on initial post, only on Modify.  Looked a little clunky, made a few cosmetic changes.  Nice mod.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

GL700Wing

Quote from: Sir Osis of Liver on December 31, 2020, 04:25:17 PM
Ok, got it working.  Dropmenu doesn't display on initial post, only on Modify.
I'm pretty sure that's how it's always been - the idea is for the image to be autorotated when it is uploaded if the EXIF data is available and to allow manual rotation after it has been uploaded - I'll check back through earlier versions when I get home to confirm.

QuoteLooked a little clunky, made a few cosmetic changes.
That change looks great - if you don't mind I'd like to incorporate it in the next release.

QuoteNice mod.
Yeah - Dougiefresh writes nice mods!
Life doesn't have to be perfect to be wonderful ...

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

Sir Osis of Liver



sprintf('<select id="orient[%1$d]" name="orient[%1$d]" style="height: 35px; margin: 0 10px 0 15px;">
<option value="1">ROTATE/FLIP IMAGE</option>
<option value="6">' . $txt['img_orientation6'] . '</option>
<option value="8">' . $txt['img_orientation8'] . '</option>
<option value="3">' . $txt['img_orientation3'] . '</option>
<option value="2">' . $txt['img_orientation2'] . '</option>
<option value="4">' . $txt['img_orientation4'] . '</option>
<option value="7">' . $txt['img_orientation7'] . '</option>
<option value="5">' . $txt['img_orientation5'] . '</option>
</select>', $attachment['id']);


Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Advertisement: