Send images in OssnMessages Download 2.1

5.0
Breton Rafael [redcrested.net] 3 years ago

An improvement on OssnMessages component to allow the user to attach images. Images also appear properly into OssnChat component, but isn't possible (yet) send images through this component.

If FancyBox component is enabled, images can be open in fullscreen mode.

Disclaimer

OSSN message system has 2 components. The OssnMessages is used in mobile version and OssnChat is the small chatbox at bottom of the page. At this version, this component only works with OssnMessage. Maybe someone here can help me to develop this part of the component :-)

Screenshots

Screenshot of OssnMessages component
Screenshot of OssnMessages component

Screenshot of OssnChat component
Screenshot of OssnChat component

How to support

If you want to help me to make more components, click on the button down bellow and buy me a coffee. It's up to you how much coffee I'll drink :-)

Changes

  • Version 2.1
    -Fixed JS error, found by Michael Zülsdorff
  • Version 2.0
    -Added desandro/imagesloaded JS file and other stuffs to fix scroll down page on load don't work propperly issue
    -Added code to delete file when user delete message. Files from deleted messages will keep into server. Sorry
    -Added code to delete file if user leave or reload page. Working in Chrome, Firefox, Edge.
    -Added button to delete an image before send. If user select another image, the old is deleted too.
    -JS file splited in two, to not inflate head section.
    -Before upload is complete, send button is disabled
    -Added TESTS.md, with test sequence used on this version
    -Images now are stored in OSSN_DATA/messages/photos/{user id} folder. Sorry for don't do this in previous versions ( Issue #1 )
    -When user is deleted, folder and files are removed too.
  • Version 1.2.1
    -Add credits to Open Social Website Core Team and OpenTeknik LLC for code used
    -Improved friendly name of component. "Allow to send images in OssnMessages" doesn't sound good to me :-)
  • Version 1.2
    -Fixed error when disable OssnMessage component, found by Michael Zülsdorff
    -Fixed warning log entry when selecting an image, found by Michael Zülsdorff
    -Add translation in Spanish. Thanks, (Hugo Cuellar)[https://github.com/Erassus]
  • Version 1.1
    -Fixed cache. Tested in both scenarios (cache on and off). Thanks again @Tamás
    -Fixed path, after Arsalam suggestion. However images sent using version 1.0 of component wont appear anymore. It's necessarily an issue to fix?
    -Fixed notification message sent/received image
  • Version 1.0
    -First release, with few tests. Use in production by your own risk.
Comments
Breton Rafael [redcrested.net] Replied 3 years ago

Michael

Thank you for point me mi mystake. I forgot to check the basics :-)

And sorry for make you check the code at 00:30.

Uploading version 1.2 today

German Michael Zülsdorff Replied 3 years ago

At this version, this component only works with OssnMessage. Maybe someone here can help me to develop this part of the component :-)

Honestly I did not understand from the very beginning why there are two almost similar channels in parallel at all? That's why I would rather drop development on one of them completely. :)

German Michael Zülsdorff Replied 3 years ago

aha ...., debugging $_FILES gives

[23-Mar-2022 00:41:07 Europe/Berlin] FILES 27 <pre>Array
(
    [uploadImageInMessage] => Array
        (
            [name] => image-message1.png
            [type] => image/png
            [tmp_name] => /tmp/phpgSYJUe
            [error] => 0
            [size] => 7691
        )

)

so, it should be

&& $_FILES['uploadImageInMessage']['size'] !== 0
German Michael Zülsdorff Replied 3 years ago

just checked 1.2 from Github:
warning is still there (line 26 now)
happening right after imagesinmessage/attachment call
but it's a little late here ... :) (00:30)

Breton Rafael [redcrested.net] Replied 3 years ago

I'll put all replies into one post :-)

@Hugo
Thanks for the feedback, test GIF file support, and the pull request into GitHub with translation to spanish. It will be released in version 1.2.

Added Cancel button suggestion into issues section on GitHub repo too.

@Michael
Thanks for the feedback. I added a <requires> to OssnMessages in ossn_com.xml. Also, I put a test to check if OssnMessage is active.

I put a test to try a solution to the warning in line 23 of ossn_com.php. However, I can't replicate this warning message. Can you make a test with GitHub version? I really appreciate your feedback before release the version 1.2

@Tamás and @Hugo (again, because is basically the same question)
OSSN message system has 2 components. The OssnMessages is used in mobile version and OssnChat is the small chatbox at bottom of the page. At this version, this component only works with OssnMessage. Maybe someone here can help me to develop this part of the component :-)

cl Erassus ︎ ︎ Replied 3 years ago

Hi, just installed v1.1 in a virtual machine for testing, no problems so far. I agree with Tamás, there's no icon in the external chatbox, but this is not a big deal and not important i think.

Also i tested with Gif Support, no errors.

Improvements suggestions:

  • Adding a delete icon to "cancel" before to send the image, what if the users select the wrong image? he can't delete the image and select another before to send the message.

enter image description here

German Michael Zülsdorff Replied 3 years ago

When selecting an image I get

PHP WARNING: 2022-03-22 08:14:41 (CET): "Undefined array key "file"" in file components/ImagesInMessage/ossn_com.php (line 23)
PHP WARNING: 2022-03-22 08:14:41 (CET): "Trying to access array offset on value of type null" in file components/ImagesInMessage/ossn_com.php (line 23)

When disabling OssnMessages I get

Error: Class "OssnMessages" not found in components/ImagesInMessage/classes/ImagesInMessage.php:12
Stack trace:
0 components/ImagesInMessage/ossn_com.php(16): require_once()
1 classes/OssnComponents.php(229): include_once('...')
2 libraries/ossn.lib.components.php(69): OssnComponents->loadComs()
3 system/start.php(39): include_once('...')
4 index.php(12): require_once('...')
5 {main}
Hungarian Tamás Varga Replied 3 years ago

Rafael: OSSN 6.1 white theme. Laptop, Chrome web browser, envelope clicking and no photo upload icon.
enter image description here

When you open menu messages, there is a photo icon.
enter image description here

Hungarian Tamás Varga Replied 3 years ago

Rafael: Photo sending is working for now, no text feedback. We test about 200 people today. Thank you very much for this opportunity.

Breton Rafael [redcrested.net] Replied 3 years ago

In GitHub I fixed these two issues (cache and path). However I finded in notification a message like [image=ME95bis5L0p instead a friendly message.

I'll try to fix this tomorrow and after that, send a new version.

Component

Developer: Rafael
License ossnv4
Type: Communication
Requires Ossn Version : 6.1
Latest Version: 2.1
Last Updated 2 years ago
Repository Url View Repository

Versions