Embed External Picture to Wall post

saqib saqib Posted in Component Development 7 years ago

I want to embed external picture which is already saved somewhere else and has a image link. i want to embed that external picture on my wall post. Just like youtube video embed but for picture not for video.

for example:

<img src= some-picture-saved-on-thirdparty-server.png />

I know there is a component for link preview but that component is just show screenshot of the website through link. But I don't want that I just want to embed external picture on my wall post. so people dont upload pictures on my server instead they share links to their photos which are already saved somewhere else. but they would be able to show those photos through link in the wall post.

Replies
us MAURICE TAYLOR Replied 3 years ago

did anyone come up with a fix for this and is there a tutorial on how to implement this for newbies?

us Aaron Kirk Replied 4 years ago

I am an idiot when it comes to PHP. How do I call the function in item.php? I added the code to ossn_com.php I think correctly but haven't figured out the item.php part.

gb Saqib saqib Replied 6 years ago

Thanks Bansh33 it is working now, all I had to do was place the function in ossn_com.php of OssnWall and then call the function from item.php, it is working fine. very nice feature to have. Also thanks to ~Z~ Man.

Is there a way to have category for each post for wall posts, for example, I want users to post football match highlights, that will be category of football and type of post will be a video link, nothing else. How can I do that any idea Bansh33?

gb Rishi B Replied 6 years ago

Saqib, check your error log. most likely there's some issue which is causing your scripts to die before they finish executing, which is probably why your css seems to disappear. Turn on error logging through the admin interface and look through your error log file.

gb Rishi B Replied 6 years ago

sorry about that, the array_push() line was some debugging code I had added and forgot to remove. I'm not really sure why you got the error about redeclaring the function name though - it worked just fine for me in item.php (and then calling it on $params['text'] before the value is echo'd). This also does not cause me any CSS issues so I'm not really sure why that would happen for you, Saqib. I've had this modification running on my site soulfulgathering.com for a few months now and it's working fine for me.

German Michael Zülsdorff Replied 7 years ago

I just tried it on https://newblue.ongolito.net/u/demoduck and had some troubles, too:
(use [DD] button on front-page to login automatically)

First, I got a fatal error:

Cannot redeclare replace_images_with_embeds() (previously declared in /newblue.ongolito.net/components/OssnWall/plugins/default/wall/templates/wall/user/item.php:108) in /newblue.ongolito.net/components/OssnWall/plugins/default/wall/templates/wall/user/item.php on line 146

The solution is to add that function to ossn_com.php of OssnWall instead of item.php

Next, I got a warning:

array_push() expects parameter 1 to be array, null given" in file /newblue.ongolito.net/components/OssnWall/ossn_com.php (line 566)

Actually, both vars are not in use - so you can remove this line completely

After having applied these changes, replacement starts working

gb Saqib saqib Replied 7 years ago

Thanks for posting solution to this problem, but I have tried your solution, it is working but when you put your php code the stylesheet doesnt work i mean all background color becomes white layout just links and not correct and i dont see the theme that i want to use can u fix this code so the styles also work with this code. Thanks Saqib.

gb Rishi B Replied 7 years ago

I didn't intend for this to be used to milk others' bandwidth, but nonetheless, I posted the code: https://gist.github.com/rishibhat/527f08a94c434b4a39872e57a6017a4e

call that function in the way mentioned in my first post

what this does is when a user posts a url which is a direct link to an image, rather than displaying the link, the picture will actually be shown. it works perfectly in conjunction with the FancyBox component also - if you click the image it will show up in a nice lightbox just like when you post an image the 'regular' way.

Indonesian Arsalan Shah Replied 7 years ago

It seems the code is removed by one of our op, with reason that it didn't shows correctly here, i suggest you to post your code on https://gist.github.com/ or similar site.

Saqib actually wanted to upload all his site images to some image storage website and wanted to use its link to display, he do not wanted to store any image on his website (the images you upload directly to the wall post from your device) i am not sure if this can be achieved using link preview or any other component. Since link preview only display images from the link posted.