News:

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

Main Menu

Fix attachment dimensions and thumbnails.

Started by JayBachatero, August 08, 2007, 01:25:12 AM

Previous topic - Next topic

JayBachatero

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.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert


JayBachatero

Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert


smashmash

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!!

JayBachatero

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.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

lcx

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 [nofollow]
I think if I modify the converter (fireboard -> SMF) to just ignore the [ img] [ /img] stuff then it should work.

JayBachatero

Well those images are not uploaded as attachments.  This script only handles images that are posted as attachments.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

GongShow

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?

SleePy

Are they valid image files?
Are you able to download the image files?

Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

GongShow

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.

SleePy

If you check the database, do these old attachments that are .jpg, .gif, etc have a id_thumb?
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

GongShow

id_thumb is zero on all attachments in the smf_attachments table

SleePy

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?
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

GongShow

I am using 1.1.7.  The images have width but not height. height are all 0

SleePy

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 :)
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

GongShow


nadrojcote

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.

Norv

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 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.
To-do lists are for deferral. The more things you write down the later they're done... until you have 100s of lists of things you don't do.

File a security report | Developers' Blog | Bug Tracker


Also known as Norv on D* | Norv N. on G+ | Norv on Github


Advertisement: