Show an image in grid

QuestionsShow an image in grid
Jim asked 10 years ago

I have a table with one field that has the filename of an image.jpg that is held in a path on the server. I would like to display a thumbnail of the image in the grid.

I could name the thumbnail with the id of the record +.jpg.

Any ideas on how I can accomplish this?

4 Answers
Abu Ghufran answered 10 years ago

For such case, you need to define column with custom html as formatter.

$col = array();
$col["title"] = "Logo";
$col["name"] = "logo";
$col["width"] = "40";
$col["align"] = "center";
$col["search"] = false;
$col["sortable"] = false;
$col["default"] = "<img height=25 src='{image_name}.png'>";
$cols[] = $col;

{image_name} in default, need that there is another column defined with this name.

Alternate option is, if you db contains complete URL of image or you can concat it in custom SQL, you can use this

$col["formatter"] = "image"; // format as image — if data is image url e.g. http://<domain>/test.jpg
$col["formatoptions"] = array("width"=>'20',"height"=>'30'); // image width / height etc


Jim answered 10 years ago

That works way to easy…

I renamed the images to the id field of the table and was able to use this:

$col["link"] = "detail.php?id={id}";
$col["linkoptions"] = "target='_self'";
$col["default"] = "<img height=35 src='images/{id}.jpg'>";

as you can see you can still have the image clickable with the linkoptions set.

Very nice grid, thanks for all your hard work on it.


Abu Ghufran answered 10 years ago

Thanks, and let me know in case of further support or wishlist.

Michaelvew answered 4 weeks ago

I have been hoping for. The details here on the forum is truely great and helpful and will help my kids and I in our studies a lot. It looks like all of the members here has a large amount of knowledge regarding this and other subjects and info really show it. I am not on the net when I am busy but when I get a break im more often than not avidly searching for this kind of knowledge and others closely having to do with it. When you get a chance, have a look at my site. [url=]buy for cash vacant house without an agent near me in Lithonia, StoneCrest Georgia 30058[/url]

Your Answer

16 + 4 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.

How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?