Support » Plugin: dbview » [Plugin: dbview] [db view] displaying of images

  • Resolved Mark Orie



    In the readme you mention that you can use PHP snippets to include an image. I have stored some images stored in the db as blobs. No idea how I would be able to display them, but very keen to learn 🙂

    I do know how to select the cells, but that just results in the table not building

    did you have a specific method in mind when you wrote that it would be possible to include an image?

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author john ackers


    Mark. I’m not sure how wp loads images from blobs in any event. If you have images in the media library, here’s some SQL to show the thumbnails in a table using dbview:

    select meta_id, post_id, meta_value as wp_attached_file, (select meta_value from wp_postmeta where post_id=pm1.post_id and meta_key='_wp_attachment_metadata') as thumbnail from wp_postmeta as pm1 where meta_key='_wp_attached_file' limit 100

    And this is the PHP snippet to drop in the top of the ‘thumbnail’ column which embeds the image into the column.

    $o = unserialize($value);
    if (!isset($o['sizes']['thumbnail']['file']))
      return "no thumbnail" ;
    $ud = wp_upload_dir();
    $imageURL = $ud['url']."/".$o['sizes']['thumbnail']['file'];
    return("<img src='".$imageURL."' />");

    This might give you a start. I’m guessing that you need a different $imageURL. I looked at the organisations page on your site and the images have gone. How did it previously work with blobs, crucially what did the HTML look like? (or What plugin to handle blob requests are you using)?

    I used to do them by hand. Those are stored in the media library.

    Then I wanted to automate things, especially the count (before, I had to update the count manually on every subscription. It seemed like a good plan to store everything I needed in a table. I made that user (read co-administrator with no coding skills whatsoever) by making a Form manager form containing 3 fields: organisation, status (active= active participant/passive=available for projects but not yet involved in any) and logo. The fields are respectively text field, dropdown list and file upload. the logo is stored in the database as a blob.

    I now realise it will be much easier to just add the logo’s to the media library and store the hyperlinks to them in the database. I might even be able to use a PHP snippet to transform the url into an img tag pointing to the same file using just the snippet you proposed or even only the last line of that. Adding the url seems easier than trying to identify the right logo in a query, especially since I need the extra table to read the status anyway.

    I made that user (read co-administrator with no coding skills whatsoever

    should be

    I made that user (read co-administrator with no coding skills whatsoever)-friendly

    yep, that works just fine.

    Tried one more thing, but that didn’t work. Can’t seem to figure out why not:

      CONCAT('<a href="', f.deelnemendeorganisatieurl, '" target="_blank"><IMG SRC="', f.deelnemendeorganisatielogourl, '" width=100 /></a>') AS Logo

    Gives me the desired HTML, but as text. Adding a snippet

    $a= html_entity_decode($row['Logo']);

    which should do something (even if it is not the right thing 🙂 offers no change

    Plugin Author john ackers


    Mark, sorry, by default, the cell data is put through encodeHtmlEntities() and nl2br() so people can see the contents of the fields. I was planning to add flags for that option but also I didn’t expect anyone to insert the HTML tags in a database select statement! However if you make return($value); the PHP snippet, you will get the value from the database without any manipulation. It works for me with your SQL statement.

    Sorry for the dirty hacks, inexperienced makes for the odd interesting solution. Did it to avoid the extra column (since I have to combine site URL and LogoURL in one cell)

    I tried this with 0.3.0. it didn’t work. I tried the same snippet before, but that didn’t work either.

    Slight problem at the moment: I upgraded to 0.3.1, but the listview seems to have stopped working, so i can not see wether the upgrade improved things. will try with just the “load”function tomorrow. Some sleep would be in order at this moment, I think.

    Plugin Author john ackers


    Understand about the column count, food for thought. Just so we are comparing apples and oranges, my SQL, which works, is

      CONCAT('<a href="', "abc", '" target="_blank"><IMG SRC="', "xyz", '" width=100 /></a>') AS Logo

    Is there absolutely no text/data generated? If you use a browser debug window e.g. on chrome, right click / select element, can you see anything in that cell? Or try changing your return to return("hello world".$a); for a sanity check.

    For good or possibly bad, listView is now loaded into wp_options on plugin activation, so it can be modified by the user. That’s probably too fragile. Have you tried deactivating and reactivating the plugin?

    After a little pause I tried to fix it, but the upgrade posed some major problems. I’ve started a new thread for that on

    Plugin Author john ackers


    Think this problem is fixed (according to

    it is. Should have posted that here too. No problems whatsoever anymore. Just two awesome plugins. Thanx!

    for those who have not seen John’s other plugins: I use eCampaign and DB view together.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[Plugin: dbview] [db view] displaying of images’ is closed to new replies.