Oracle Apex: One Method to display an image from a table

 Requirement

You have an image in a table and want to display it on a page.

There are a number of options. 

1. Creating an Ajax callback application process and using a URL: to fetch it. e.g <img src="f?p=&APP_ID.:0:&APP_SESSION.:APPLICATION_PROCESS=GETIMAGE:::IMAGE_ID:4">

2. Creating a display image item type with source SQL Blob column.

..or if these don't work and sometimes they don't for no rhyme or reason, here is a method that looks obscure but worked beautifully for me.

Method

Create a classic report with the following query, mine was on page 9:

select '<img src="'||apex_util.get_blob_file_src(p_item_name => 'P9_IMAGE',p_v1 => to_char(product_image_id), p_v2 => null, p_content_disposition => 'inline') || '" class="thumbimage" />' img

   from [your_table]

/*Make sure to set the Escape special Characters to No under the Security section of the column "IMG"*/



Create a page item in the same region as the report.

  • Name (Identification section): P9_IMAGE
  • Type: Hidden
  • Value Protected (Settings section): No
  • Type (Source section): Database Column
  • Database Column: CONTENT [Change accordingly]

and another.

  • Name (Identification section): P9_PRODUCT_IMAGE_ID
  • Type: Hidden
  • Value Protected (Settings section): No
  • Type (Source section): Database Column
  • Database Column: PRODUCT_IMAGE_ID [Change accordingly]
  • Create a new process


  • Name
     (Identification section): Fetch Image
  • Type: Automatic Row Fetch (Note this is a legacy type)
  • Table Name (Setting section): PRODUCT_IMAGES [Change accordingly]
  • Primary Key Column: PRODUCT_IMAGES_ID [Change accordingly]
  • Primary Key Item: P9_PRODUCT_IMAGE_ID (i.e the column we defined above)
  • Point (Execution Options): Before Header

Result

One image


You can fiddle with the format and styling as you want after that.

Acknowledgment




Comments