This topic is locked

hotlinking images

12/19/2014 3:58:57 AM
PHPRunner General questions
C
cristi author

I want to build a media sharing site.

The users can upload pictures (up to 5) and then hotlink the pictures to a forum.

I created a database with 3 fields: ID, picture, link.

The picture field is defined as "image" with display thumbnails and set of thumbnails with preview options for the view as option and file/image for the edit as option.
Now, on the list page I want the link field to display a link for each picture that the user clicks in the field - I will have picture field populated with one picture, two, three up to five.
I managed to achieve this by setting the link field as custom and inserting the following code:

$pic=json_decode($data["picture"], true);

$date='';

foreach($pic as $value){

$date.= "[img]http://xxx/";. $value["name"]."[/img]<br/>";

}

$value=$date;


This works but I want - in the case that are more than one images uploaded for the picture field to display the corresponding link each time than the user click that picture in the set of thumbnail with preview (and make invisible the other links for the pictures in the set of thumbnails) or to highlight the corresponding link for the clicked picture.
Also, in the add page I want that each time a picture is uploaded the link of that picture to be added to the link field - any suggestion on how can I achieve this??? - custom field is not an option on the add page so I think that I need to use javascript??? How can I decode the real link (for hot-linking) of the uploaded image in javascript?

Sergey Kornilov admin 12/23/2014

I'm still not quite sure I understand what kind of problem you trying to solve and how we can help. Try to rephrase it.

C
cristi author 12/23/2014

O.K.
The list page - I figured it out.
On the "Add page" I have an upload field. The user can upload up to seven files.

Basically what I want to know is this: after the user press the "upload" button for each file in an text area field below the upload field the real links for the files with bbcode already attached should be generated.
For example: the user upload 2 image files and after the user presses the upload button for each file in an text area below the upload files field the link for each file should appear for copy with [img] bbcode attached.
Can this be done easy?

Sergey Kornilov admin 12/23/2014

Yes, this can be done but this won't be easy. Quite a bit of coding will be expected if you need to add this functionality right to the Add page. IT will be much easier on pages like View or List.