Issue with image in article submission form Joomla

How to prepend an uploaded image to intro text in a Joomla article submission form without replacing it.

Overview

The issue occurs because the custom code incorrectly assigns the image tag to the intro text field, overwriting the existing content.
Modify the code to concatenate the image tag with the existing intro text value instead of replacing it.

Answered
ji jigsaw 10 May, 2016
Hi there,

I have used the info provided here: http://www.chronoengine.com/forums/posts/f5/t65646.html?page=1 to add an image to the submit article form as explained but somehow it replaces the complete intro text with the uploaded image.

I am trying to place the image before the intro text but after spending plenty of time i am hoping for some support.

The custom code i am using is:

<?php
$uri = JFactory::getURI();
$img_tag = "<img src='{$uri->root()}images/ingezonden/{$form->data['intro-image']}' alt='image' />";
// add the image to the introtext
$form->data['introtekst'] = "{$img_tag} ";
?>


I have named the image upload intro-image and for the joomla article submission i have the following id's

title
artikeltekst
introtekst

I suspect that the issue comes from this line; $form->data['introtekst'] = "{$img_tag} ";

Below i have my debug details:

Data Array

Array
(
    [option] => com_chronoforms5
    [view] => form
    [Itemid] => 147
    [chronoform] => artikel-inzenden
    [event] => submit
    [title] => Article with intro image
    [introtekst] => <img src='http://www.suc6fulwomen.eu/main/responsive/images/ingezonden/20160510150350_20150802_091812.jpg' alt='image' /> 
    [artikeltekst] => <p>This is the complete article text</p>
    [button4] => Verzenden
    [intro-image] => 20160510150350_20150802_091812.jpg
    [ip_address] => 195.240.139.137
)

Array
(
    [intro-image] => Array
        (
            [name] => 20160510150350_20150802_091812.jpg
            [original_name] => 20150802_091812.jpg
            [path] => /var/www/vhosts/suc6fulwomen.eu/httpdocs/main/responsive/images/ingezonden/20160510150350_20150802_091812.jpg
            [size] => 4025605
            [link] => http://www.suc6fulwomen.eu/main/responsive/images/ingezonden/20160510150350_20150802_091812.jpg
        )

)

Errors

Array
(
)

Debug Info

Array
(
    [4] => Array
        (
            [Files Upload] => Array
                (
                    [0] => Upload routine started for file upload by : intro-image
                    [1] => /var/www/vhosts/suc6fulwomen.eu/httpdocs/main/responsive/images/ingezonden/20160510150350_20150802_091812.jpg has been uploaded successfully.
                )

        )

    [3] => Array
        (
            [Email] => Array
                (
                    [0] => An email with the details below was sent successfully:
                    [1] => To:info@jigsaw-webdesign.nl
                    [2] => Subject:Er is een nieuw tekstartikel op www.suc6fulwomen.eu aangeboden
                    [3] => From name:Suc6ful Women
                    [4] => From email:teja@suc6fulwomen.eu
                    [5] => CC:
                    [6] => BCC:
                    [7] => Reply name:
                    [8] => Reply email:
                    [9] => Attachments:
                    [10] => Array
                        (
                            [0] => /var/www/vhosts/suc6fulwomen.eu/httpdocs/main/responsive/images/ingezonden/20160510150350_20150802_091812.jpg
                        )

                    [11] => Body:
<table>
<tr><td>Titel artikel</td><td>Article with intro image</td></tr>
<tr><td>Intro afbeelding</td><td>20160510150350_20150802_091812.jpg</td></tr>
<tr><td>Plaats hier de intro tekst</td><td><img src='http://www.suc6fulwomen.eu/main/responsive/images/ingezonden/20160510150350_20150802_091812.jpg' alt='image' /> </td></tr>
<tr><td>Volledig artikel</td><td><p>This is the complete article text</p></td></tr>
</table><br /><br />IP: 195.240.139.137
                )

        )

)
Gr GreyHead 10 May, 2016
Answer
Hi Jigsaw,

Please try
$form->data['introtekst'] = $img_tag.$form->data['introtekst'];

Bob
ji jigsaw 10 May, 2016
Hi there Bob,

That did the trick, thanks a lot for the outstanding support.

Harrold
This topic is locked and no more replies can be posted.