ATutor

Learning Management Tools







Pages:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15


Base64 Images for Forums


  • 2012-12-24 17:56:21

    Base64 Images for Forums

    I'm working on developing the ability to add sketches to forum posts and I'm wondering if image data in base64 encoding (not sure I'm saying that right) can be stored in the DB, then rendered on the forum page to show the image.

    Is this currently possible?

    Thanks.

  • 2012-12-25 09:41:55

    Re: Base64 Images for Forums?

    Apparently not with the current version of MySQL, but it appears to be coming.

    http://stackoverflow.com/questions/358500/base64-encode-in-mysql

    You'd be better off saving files to the content directory as image files for now.

  • 2012-12-25 14:44:58

    Re: Base64 Images for Forums?

    This actually seems to be currently available when posting announcements.

    I posted the following announcement by dragging an image file into the tinyMCE area when making the announcement. Then I copy/pasted the text version here for testing purposes. The image even came through on the email I received of a newly posted announcement.

    Since announcement html is stored in the DB, couldn't the same be achieved with forum posts?

    <p>here's a base64 encoded image</p>
    ----cut----

  • 2012-12-26 11:40:01

    Re: Base64 Images for Forums?

    Nice! That's a feature I did not know existed in TinyMCE. We'll have to give that a closer look, or if you're experimenting let us know what you find.

    It would be interesting to see how these images are handled in cartridge or package exports.

  • 2012-12-26 11:52:18

    Re: Base64 Images for Forums?

    Well, I tried it in a forum post and it didn't work. I know that HTML is disabled in forums..... would there be a way to allow just base64 encoded images and block other HTML content?

    Probably not, but I thought I'd ask.

  • 2012-12-26 12:06:53

    Re: Base64 Images for Forums?

    Its a TinyMCE feature, so you'd need to get it into the Forum post editor. Perhaps a highly trimmed down version could be used to post to forums. If HTML is allowed in forums however, you run the risk that broken HTML will get into messages and potentially mess up the display of threads.

  • 2012-12-26 12:11:34

    Re: Base64 Images for Forums?

    I think the issue is on the display end of things though. I put some HTML in a post and the HTML is "remembered" as HTML in the DB (i.e. <b>this is bold</b>).

    However, when that HTML is displayed in the forum post, the HTML isn't rendered. It displays like this: <b>this is bold</b>.

    The same is true of base64 encoded data. So, the question is how to allow the displaying of some HTML data in the forums.

  • 2012-12-26 14:47:15

    Re: Base64 Images for Forums?

    Perhaps have a look at the print_entry() function in /mods/_standard/forums/lib/forums.inc.php

  • 2012-12-26 15:14:40

    Re: Base64 Images for Forums?

    Right.

    The line in question seems to be
    [php]<p><?php echo AT_print(htmlspecialchars($row['body'], ENT_COMPAT, "UTF-8"), 'forums_threads.body'); ?></p>[/php]

    However, when I change it to
    [php]<p><?php echo AT_print($row['body'], 'forums_threads.body'); ?></p>[/php]
    to allow HTML content to be displayed, <b>this is bold</b> still displays as <b>this is bold</b> instead of [b]this is bold[/b].

    Am I not adjusting the proper thing?

  • 2012-12-26 16:20:44

    Re: Base64 Images for Forums?

    Look at the AT_PRINT() function's formatting constants. You'd need to change forums_threads.body to something that allows HTML, like the content.text format for now.

    These formats are defined in:
    include/lib/constants.inc.php

    If you are thinking about getting your changes into ATutor as a permanent feature, you should considered developing a forum property to allow or disallow HTML, switching between the HTML and non-HTML formats on a forum by forum basis.

    Admins should also have the ability to control whether instructors can turn on HTML in forums.

    It might also be a good idea to create a new format (e.g. forums_threads_html.body), perhaps a limited HTML format that prevents use of HTML that might result in security or presentation issues, and add that to the AT_print() function in include/lib/output.inc.php.

    There may be other issues that need to be addressed to securely allow HTML in forum posts. It's something we looked at a long time ago, and concluded there were too many issues to allow students to use HTML in posts. There are probably newer methods now that would make HTML use more practical. Some research would be needed.

  • 2012-12-26 16:34:15

    Re: Base64 Images for Forums?

    This is getting beyond my skill set at this point.

    I think the best solution may be to have sketch data that's base64 encoded converted to an image file and saved on the server. Then it could be displayed using the [image] [/image] tags.

    Can the [image] [/image] tags reach images in the content dir. or is that only for showing images that the general public would have access to? It would be nice to keep these somewhat secure, but it's not critical.

    Thanks for the support!