This topic is locked
[SOLVED]

 Display image from URL in db

11/20/2015 2:13:12 PM
PHPRunner General questions
S
snuffi01 author

I guess that this is simple, but i cant figure it out...

In my db i have an field with url to images on avatar of linkedin members (https://media.licdn.com/mpr/mprx/......)

I want to display the image on listpage not the url.
/ Kristian

admin 11/20/2015

This is fairly straightforward. Set 'View as' type of this field to 'Custom' and use the following code:

$value = "<img src='".$value."'>";
S
snuffi01 author 11/20/2015



This is fairly straightforward. Set 'View as' type of this field to 'Custom' and use the following code:

$value = "<img src='".$value."'>";



Thanks, that helped!
Is it possible to also control the size on the listpage of the image?

admin 11/20/2015

Sure, you can add width and height attributes to img tag.

$value = "<img width=100 height=100 src='".$value."'>";
S
snuffi01 author 11/21/2015



Sure, you can add width and height attributes to img tag.

$value = "<img width=100 height=100 src='".$value."'>";



I'm trying to show an avatar image if the field is empty, trying this code (doesnt work)

The field witch has the url is called AvtarURL
if ($data["AvtarURL"].length == 0){

$value="<img src=\"images/phone-green-50px.png\">";

}

$value = "<img width=75 height=75 src='".$value."'>";
Also tried this code:
if (".$value.".length == 0){

$value="<img src=\"images/phone-green-50px.png\">";

}

$value = "<img width=75 height=75 src='".$value."'>";
/ Kristian

admin 11/23/2015

In PHP you can use strlen() function to find the string length:

http://php.net/manual/en/function.strlen.php