News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

SVG As Image Attachment Support

Started by dougiefresh, March 01, 2016, 06:41:40 PM

Previous topic - Next topic

dougiefresh

Link to Mod



SVG AS IMAGE ATTACHMENT SUPPORT v1.5
By Dougiefresh -> Link to Mod



Introduction
This mod allows the forum to properly process a SVG file so that it is displayed as an image beneath the post, complete with original image dimensions and size, instead showing of a download-only link for the SVG file.  It will also attempt to convert the SVG image to either a PNG image, provided that the PNG function and the ImageMagic extensions are installed.  If the PNG functions aren't available, then it will convert it to a JPEG image.

Upon install, this mod attempts to change any existing SVG file attachments so that they can be viewed.

Upon uninstall, this mod removes the image dimensions from SVG images in order to prevent SVG thumbnails from being shown at full size.

Admin Settings
There are two new buttons under Admin -> Forum -> Attachments and Avatars -> File Maintenance, at the bottom of the page under SVG Attachments.

The 1st button will populate existing SVG files that don't have image dimensions and mime-type data in the attachments table, while the 2nd button removes the image dimensions from the attachments table.

Compatibility Notes
This mod was tested on SMF 2.0.11 and SMF 2.1 RC2, but should work on SMF 2.0 and up.  SMF 2.1 Beta 3 and SMF 1.x will not be supported.

PM Attachments should be installed prior to this mod being installed if you want SVG attachments in Personal Messages to show up properly.

Changelog
The changelog can be viewed at XPtsp.com.

License
Copyright (c) 2016 - 2019, Douglas Orend
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

dougiefresh

Uploaded v1.1 - December 11th, 2016
o Changed mod uninstall code to look for mime type instead of file extensions.
o Added SMF 2.1 support to the mod.  No changes for SMF 2.0.x-branch.

dougiefresh

Uploaded v1.2 - July 8th, 2017
o Added support for SMF 2.1 Beta 3.
o Removed support for SMF 2.1 Beta 2.

dougiefresh

Uploaded v1.3 - November 8th, 2018
o No functionality change.
o Updated documentation to point to new website.

-Rock Lee-

I thought I translated it ... layers was dejavu ::) I leave the translation!


Regards!
¡Regresando como cual Fenix! ~ Bomber Code
Ayudas - Aportes - Tutoriales - Y mucho mas!!!

dougiefresh

Uploaded v1.4 - November 9th, 2018
o Added Spanish Latin translation, courtsey of Rock Lee!




@Rock Lee:  Thank you for the translation!  It's been included in this version!

dougiefresh

Uploaded v1.5 - May 22nd, 2019
o Added support for SMF 2.1 RC2.
o Removed support for SMF 2.1 Beta 3.

shadav

so i installed this and thought it was fine...
today I was trying to edit a board when I get this error

Call to undefined function svg_getimagesize()

I'm assuming it's due to this mod

[edit] on a 2.0.17

brynn

Hi Friends,
I'm not sure if you will remember me.  It looks like this topic must have replaced an older one, because I was helping to test versions 1.0.1 through 1.0.4 of this mod (my notes dated Feb 26, 2016) and I posted many times in the support topic for this mod, at that time.

Anyway, I'm helping to start another SMF forum for supporting Inkscape, the open source vector graphics editor (i.e. it edits SVG files, and we want to display SVG images, if possible).  So we need this mod. It worked great in my first SMF forum!

When I install it through the automated route, I get this error:

"The package you are trying to download or install is either corrupt or not compatible with this version of SMF."

We're using SMF version 2.1.3.

Is there any way to know which is the problem, except by trying to install it manually?

Hhmm, actually I just went back to the Browse Packages page, and I see it's still uploaded to the Package Manager.  But where the Install or Uninstall Mod button should be, is a button "Install Emulating 2.1RC2".

So I found this page and read it through: https: //wiki.simplemachines.org/smf/How_can_I_install_a_mod_that_doesn%27t_work_in_my_SMF_version  And then I tried emulation.

Unfortunately, emulation failed.  Among the reasons it gave were that another mod might be preventing it from installing.

So I uninstalled the only other mod that we had installed. And then tried again, with identical results.

Does this mean something is corrupt?  Or would there be any hope that it might work by manually installing (assuming that I can figure out how to) ?

Thank you very much!

Arantor

No, it's that the mod hasn't been updated since 2.1 RC2 (which is before 2.1.0) and doesn't have any install instructions for 2.1.3. Emulation is then just "use the install instructions from 2.1 RC2"

It should give you a list of operations it's trying to do, with "test failed" items as to which ones failed...

brynn

Yes, it does.  I made a screenshot of it. 4 files have the red "Test failed".

But I.... 

Oh, I might be starting to remember.  It tells you how to fix it, right?

Ok, now I found this page:  https://wiki.simplemachines.org/smf/Error_in_mod_installation
Are those the instructions I need now?

Oh dear....  Is there any way to do this, without access to the server?

With my old website, I owned the server, so I could do it all myself.  But with this project, my friend has the server, and she does not know much about SMF.

Would it work if I only had upload rights to the server? Or would I need both download and upload rights? Hhm, maybe she can limit which part of the directory I can use, or something like that?

Thanks for your patience as I re-learn all this  :)

Arantor

You can't really have upload rights without download rights on an FTP server - it has to download the list of what files there are in the first place. But you will need server access to install this as it is telling you "I can't install this automatically".

It may be that the mod needs more extensive changes than it might seem - 2.1 RC2 was quite a bit back compared to 2.1.3...

brynn

Well, I don't know if she uses FTP, or the file manager.  I guess what I was really asking, is do I need to download the problematic files from the server?  Or can I get them from my local file manager?  I don't know if installing them changes them in some way?

If I can get them from the original package I downloaded, then I could fix them, and give them to her to upload.  It would be a clunky workflow, but it would preserve the integrity/security of the server.

Of those 4 red "Test failed" files, only 2 of them have instructions.  And they look fairly small.

Are you saying that even if I make the changes, it still might not be able to install? Or it might install but might not work?

If it still won't install or work, does that mean I need to just wait for it to be updated? Is there some kind of procedure to request an update?
Because I certainly don't have the skills to write it mysellf!!

Arantor

It does sound like it needs more work than just a quick tweak or two :( as for "requesting an update" that's usually just by posting in the mod's topic, and here we are...

brynn

Sigh!

Ok then.  I will try the 2 fixes, assuming my friend and I can work out server access for me. I do trust your expertise, but I guess it can't hurt to try.

Hopefully dougiefresh will see this!

Would it be bad forum manners to put a message on the Mod Request board, to ask for a similar mod which works with the current version of the forum? (It does not look like a huge mod.)

Thank you very, very much for answering my questions, and your patience!

Arantor

No, not at all - I don't know if dougiefresh still drops by - I've been on hiatus myself for a while - but hopefully someone can take a look.

brynn

Ok, I'll make a request.

Thanks again for your time and attention  :)

brynn

Ok here's the request for a new mod:  https://www.simplemachines.org/community/index.php?topic=585170.0

But I'd be just as tickled to see dougiefresh again!


Advertisement: