How to include graphical content


The use of CGI incites us to manage pictures, however – although it would be possible in principle to store images as blobs within the database – I have chosen to proceed differently, in order to keep unid bases not too big.

As of Unidatab-CGI version 1.1.1, images are stored in a dedicated directory within the HTTP server path and the mention of a word ending in .jpg or .gif  makes the server check for the existence of an image of this type in there.

The path of the image directory can be set in Unidatab.cgi (variable $UNID_PIX) and defaults to http://localhost/devel/Unidatab/image/.

Again, users can define this way some kind of image policy of their own by specifying naming conventions. For instance, one could impose that images from one database should be differentiated by a prefix. The picture “saturn.jpg” would be renamed “test-saturn.jpg” in order to visualize clearly which content pertains to which db simply looking at the value of $UNID_PIX. However the Perl code doesn’t require anything like this,  saturn.jpg is accepted as well as test-saturn.jpg.

The size of displayed image is limited by height to the value of $PicSize (120 px), and – as images may appear in titles too – the size of  related thumbnails in lists is limited by $IcSize to 40 pixels. Both of these variables can be set in the user-defined values of Unidatab.cgi.

Here are screenshots of theses results:

 

A list of records with a thumbnail corresponding to an image title. (notice the little bug bottom right: this “oneliner connection” shouldn’t be there, an unexpected result of some suite of actions… to correct)

 

A record; title with picture.

 

If we look at the symbol id=-485, with unid-adm, the db input strings look like :

[1: /test.unid ] ? select show_symbol(-485)
show_symbol(-485) ~ :
i     ~ a    ~ d  ~ n     ~ t               ~ u                    ~  
-485  ~ 221  ~ 0  ~  220  ~  1541836361952  ~  1537979864000        
~ location:test-milkyway.jpg https://en.wikipedia.org/wiki/Milky_Way (the Milky Way).
~ This test-saturn.jpg is Saturn. ~

 

The rough example above suggests some educational benefit one could expect from Unidatab.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s