Page 1 of 1

show image from url

Posted: 2019-10-07 21:28
by tvloeimans
Hi all,

I'm building a product system and want to display a image from a url given in the product details. So this is in the database and I want to display this on the page.

How can I do this the best way?

Thanks,
Tim

Re: show image from url

Posted: 2019-10-08 06:41
by pbottcher
Hi,

just to clarify, the url is in the database and that points to an "external" image (an image that does not belong to you app)?

Re: show image from url

Posted: 2019-10-08 07:29
by tvloeimans
pböttcher wrote:
2019-10-08 06:41
Hi,

just to clarify, the url is in the database and that points to an "external" image (an image that does not belong to you app)?
Yes, to a external url like supplier website or CDN.

Re: show image from url

Posted: 2019-10-08 08:53
by pbottcher
Hi,

you can add to the TABLENAME.php -> TABLENAME_dv function something like:

Code: Select all

	$url=YOUR_SQL_STATEMENT_TO_RETRIEVE_THE_URL;
	$html.=<<<EOC
	<script>
		\$j(SPACE_TO_PUT_THE_IMAGE_AFTER).after('<img src="$url">');
	</script>
EOC;

Re: show image from url

Posted: 2019-10-08 15:42
by tvloeimans
Ok, will try that later.

Guess there is no build-in option for this unfortunately.

Re: show image from url

Posted: 2019-10-08 16:23
by jsetzer
You should have a look at the new SQL Query feature of 5.80. You should be able to use the SQL concat() function to concat a valid <img>-Tag including the src="" attribute.

Just an idea.
Best,
Jan

Re: show image from url

Posted: 2019-10-08 17:58
by tvloeimans
just testing with the tip of Jan...

Used this code in the SQL Query field

Code: Select all

SELECT `products`.`item_img_upload` FROM `products` 
CONCAT(`Show`,`products`.`item_img_upload`,`IMG-URL`)
Result in only the SQL data, not the other strings that I added.
Adding html tags kills the query...

Re: show image from url

Posted: 2019-10-15 10:31
by tvloeimans
also tested with this code:

Code: Select all

SELECT CONCAT(
'<img src="',
`products`.`item_img_upload`,
'">'
) FROM `products`
WHERE `products`.`id`='%ID%'
I only get the value as a return, not the CONCAT string...
Anyone with an idea what goes wrong here?