Simple Machines Community Forum

SMF Support => Converting to SMF => Topic started by: JayBachatero on August 08, 2007, 01:25:12 AM

Title: Fix attachment dimensions and thumbnails.
Post by: JayBachatero on August 08, 2007, 01:25:12 AM
After seeing so many topics with people having problems with attachments conversion and thumbnails, I decided to write up a small script to fix this.  What this does is that it goes into the attachments table and looks for attachments that are images but don't have dimensions set.  When dimensions are not set SMF can not make the thumbnails for the attachments and just shows you a link to download the file.  Running this script will fix this.  Please note that this script will not make the thumbnails themselves.  Thumbnails will be made once you visit the topic for the attachments.

Also keep in mind that this is still in beta.  Backup before running it.
Title: Re: [BETA] Fix attachment dimensions and thumbnails.
Post by: funkdabootiest on August 09, 2007, 12:54:59 AM
so far so good for me :D thanks!
Title: Re: [BETA] Fix attachment dimensions and thumbnails.
Post by: JayBachatero on August 09, 2007, 01:17:28 AM
So this worked for you?
Title: Re: [BETA] Fix attachment dimensions and thumbnails.
Post by: funkdabootiest on August 09, 2007, 10:21:33 AM
Quote from: JayBachatero on August 09, 2007, 01:17:28 AM
So this worked for you?

Yeah, haven't run into problems as of yet
Title: Re: [BETA] Fix attachment dimensions and thumbnails.
Post by: smashmash on November 13, 2007, 07:55:04 AM
Jay - I just imported a 1.0.8 database into 1.1.4 forum and had exactly this problem. Your fix seems to have sorted the majority of my 'missing' pic previews although I did get quite a few 'file doesn't exist' errors while it was processing.

Either way - major thanks for your time on this fix - the missing previews were driving me mad!!
Title: Re: [BETA] Fix attachment dimensions and thumbnails.
Post by: JayBachatero on November 13, 2007, 10:29:57 AM
Glad to hear it worked fine for you.  I guess I should make this an all around type script.  I wasn't expecting it to work on an upgrade.
Title: Re: [BETA] Fix attachment dimensions and thumbnails.
Post by: lcx on February 06, 2008, 02:28:22 AM
Thanks, working perfect. The only problem I still have is that I still have the large images in the Post also. This is how it's looking: http://test.vwclub.ro/smf/index.php?topic=549.210
I think if I modify the converter (fireboard -> SMF) to just ignore the [ img] [ /img] stuff then it should work.
Title: Re: [BETA] Fix attachment dimensions and thumbnails.
Post by: JayBachatero on February 06, 2008, 02:31:09 AM
Well those images are not uploaded as attachments.  This script only handles images that are posted as attachments.
Title: Re: Fix attachment dimensions and thumbnails.
Post by: GongShow on December 01, 2008, 12:44:29 AM
Hi,

I am trying to use this with 1.1.7 and it does not seem to be doing the trick. No errors but still no thumbs showing. Any suggestions?
Title: Re: Fix attachment dimensions and thumbnails.
Post by: SleePy on December 02, 2008, 02:09:51 PM
Are they valid image files?
Are you able to download the image files?

Title: Re: Fix attachment dimensions and thumbnails.
Post by: GongShow on December 03, 2008, 03:13:19 AM
Yes, I can download the images and view them just fine. And new images show thumbs as they should.

http://www.thegongshow.ca/index.php?topic=443.0

Here is a sample if it helps.

Thanks.
Title: Re: Fix attachment dimensions and thumbnails.
Post by: SleePy on December 05, 2008, 02:33:59 PM
If you check the database, do these old attachments that are .jpg, .gif, etc have a id_thumb?
Title: Re: Fix attachment dimensions and thumbnails.
Post by: GongShow on December 06, 2008, 12:59:38 AM
id_thumb is zero on all attachments in the smf_attachments table
Title: Re: Fix attachment dimensions and thumbnails.
Post by: SleePy on December 11, 2008, 04:56:17 PM
Are you using SMF 2.0? The script will not work with SMF 2.0 at this moment.

Looking at the script. Do they also have a height/width?
Title: Re: Fix attachment dimensions and thumbnails.
Post by: GongShow on December 11, 2008, 08:39:15 PM
I am using 1.1.7.  The images have width but not height. height are all 0
Title: Re: Fix attachment dimensions and thumbnails.
Post by: SleePy on December 14, 2008, 07:27:32 PM
Sorry for the delayed reply, its been finals and chirstmas shopping with lots of work inbetween :|

Ok, that is what is messing up SMF. It finds one and thinks it is setup.

Run this database query:
UPDATE smf_attachments
SET width = 0
WHERE height = 0;


This will reset the height and width.
Then the above script should work hopefully just fine to find the heights and widths again.


Once SMF has a valid height and width, once you view the image it automatically generates a thumbnail for it if its missing. Which may mean the first load of a topic with the attachment may be slow, but after that it would be fast :)
Title: Re: Fix attachment dimensions and thumbnails.
Post by: GongShow on December 14, 2008, 11:56:37 PM
That did the trick. Thanks for the help.
Title: Re: Fix attachment dimensions and thumbnails.
Post by: nadrojcote on January 12, 2010, 03:28:53 PM
I am wondering if there is anyway this could have messed up my site, I am using smf 1.1.11 and utf-8 I ran this file and after the page doesnt show properly in internet explorer. in firefox and chrome it works just fine but in ie everything seems to be a bit off. as well my chat system that is in the footer shows at the very bottom of the page now.
Title: Re: Fix attachment dimensions and thumbnails.
Post by: Norv on January 13, 2010, 07:21:15 AM
nadrojcote: it seems unlikely. What else happened to the layout or any of your files? What theme are you using and does it happen on the default theme? Might be worth not answering here, but in a Support topic of its own (the SMF 1.x Support (http://www.simplemachines.org/community/index.php?board=9.0) board is more appropriate for the issue since more likely to receive useful feedback for your layout problem), and please rest assured that if something seems related to picture attachments sizes in db, then the relation with this file can be reconsidered.
Title: Re: [BETA] Fix attachment dimensions and thumbnails.
Post by: DJFriar on February 11, 2010, 08:04:16 PM
Quote from: funkdabootiest on August 09, 2007, 12:54:59 AM
so far so good for me :D thanks!

Where is the script?
Title: Re: Fix attachment dimensions and thumbnails.
Post by: Norv on February 12, 2010, 12:08:41 AM
Please find it attached in the first post. You need to be logged in to see attachments. :)
Title: Re: Fix attachment dimensions and thumbnails.
Post by: Gerkin on August 10, 2010, 08:31:41 PM
Is there any extra undocumented trick for getting this to work?  I've just finished a conversion from IPB 2.3.x and all the posted image thumbnails are missing.  I've run this a couple of times but no luck so far ... has something changed since this was made?  I'm very comfortable with PHP and MySQL if there's something I can try manually ...
Title: Re: Fix attachment dimensions and thumbnails.
Post by: Gerkin on August 10, 2010, 08:45:33 PM
Quote from: Gerkin on August 10, 2010, 08:31:41 PM
Is there any extra undocumented trick for getting this to work?  I've just finished a conversion from IPB 2.3.x and all the posted image thumbnails are missing.  I've run this a couple of times but no luck so far ... has something changed since this was made?  I'm very comfortable with PHP and MySQL if there's something I can try manually ...

I think I found the issue and sorted it (it's still fixing things but it looks like it will be fine now).  For some reason on my conversion it brought across image width's for everything, but not height.  This script looks for everything with both height and width set to 0.  A small edit (removed the AND width = 0 link from the query) and things seem to be working.

Hope this helps if anyone else runs into this.
Title: Re: Fix attachment dimensions and thumbnails.
Post by: Norv on August 11, 2010, 06:11:57 AM
Thank you for sharing the issue and your solution, I will look into it. I thought the conversion was supposed to set both the width and height of the image, tbh, but not the thumbnails. Normally thumbnails should be able to be regenerated from ACP, attachments maintenance.