Page 1 of 1
Displaying an uploaded image?

Posted:
Mon Feb 02, 2009 6:34 pm
by sophistry
I'm having the hardest time figuring out how to get an uploaded image to display as a logo in a record.
I'm avoiding using a BLOB field, as I don't want to bulk the database up to large.
The field is VARCHAR(2048) and my fields.ini looks like this for the table:
[ref_image]
Type = container
logo = 1
widget:type = file
allowed_extensions = jpg,jpeg,gif,tga,tif
No matter what I do or change with the fields.ini, the field either comes up blank, as regular text, or wants me to open up the image in a new window. Won't display in the record. Is there a size restriction or something?
Thanks,
Rory

Posted:
Mon Feb 02, 2009 10:06 pm
by shannah
Try adding a field named ref_image_mimetype to your table (varchar) to hold the mimetype of the file. Xataface will know what to do with it.
Image display in List view

Posted:
Sun Mar 29, 2009 5:32 pm
by sophistry
Hey Steve,
This helped me out when trying to put reference shots into my database, but I have a related question...
How can I get the image to display in the List view, the same way it's displayed in the record view? It only displays the path to the image. Maybe the only way to do it is by storing the image in the database itself instead of uploading it to a directory?
Thanks,
Rory

Posted:
Thu Apr 02, 2009 6:54 pm
by shannah
You can do this using the renderCell() method in your delegate class to customize how the field is displayed.
e.g.
- Code: Select all
function my_image__renderCell(&$record){
return '<img src="'.$record->display('my_image').'"/>';
}
Procedure for displaying logo

Posted:
Tue May 05, 2009 6:53 pm
by cwight27
I attempted to piece this information in the post and it generated an error does anyone know the step by step procedure.

Posted:
Tue May 05, 2009 11:47 pm
by fongchun
I made a post about this on my blog which goes through a step by step procedure on how to do it. You can find it
here.
Re: Displaying an uploaded image?

Posted:
Thu Jun 10, 2010 10:00 am
by librarymark
Is there a way to make the image show up on the list view and the edit view?
Re: Displaying an uploaded image?

Posted:
Thu Jun 10, 2010 10:06 am
by shannah
Yes. Which are you having trouble with right now? The list view or the edit view?
Re: Displaying an uploaded image?

Posted:
Thu Jun 10, 2010 10:09 am
by librarymark
Wow - that was quick! thanks!
I can get the images to show up in details view, but it does not show up in edit or list. This is the code I am using in my delegate class:
- Code: Select all
function image_id__htmlValue(&$record){
return '<img src="'.$record->display('image_url').'" width="400"></img>';
}
Re: Displaying an uploaded image?

Posted:
Thu Jun 10, 2010 10:27 am
by shannah
For list view, use the xxx__renderCell() method:
- Code: Select all
function my_image__renderCell(&$record){
return '<img src="'.$record->display('my_image').'"/>';
}
For edit view, you will likely want to implement a before_xxx_widget() block to display your image (where xxx is the name of the field before which it should appear.
- Code: Select all
function block__before_my_field_widget(&$record){
echo '<img src="'.$record->display('my_image').'"/>';
}
Re: Displaying an uploaded image?

Posted:
Thu Jun 10, 2010 10:56 am
by librarymark
Again, many thanks. The list and detail view are now working great. Still having trouble with the edit view. When I put in this code:
- Code: Select all
function block__before_image_id_widget(&$record){
return '<img src="'.$record->display('image_url').'" width="400"></img>';
}
(image_id is the name of the field)
When i click on edit, I get this error:
- Code: Select all
Fatal error: Call to a member function display() on a non-object in /var/www/historical_new/jane/historical_images/tables/image_data/image_data.php on line 12
What am I missing? Here is my delegate class now:
- Code: Select all
<?
class tables_image_data {
function image_id__htmlValue(&$record){
return '<img src="'.$record->display('image_url').'" width="400"></img>';
}
function image_id__renderCell(&$record){
return '<img src="'.$record->display('image_url').'" width="200"></img>';
}
function block__before_image_id_widget(&$record){
return '<img src="'.$record->display('image_url').'" width="400"></img>';
}
}
?>
Re: Displaying an uploaded image?

Posted:
Thu Jun 10, 2010 11:01 am
by shannah
Sorry... my mistake... blocks don't take the record as a parameter.
should be more like:
- Code: Select all
function block__before_myfield_widget(){
$record =& Dataface_Application::getInstance()->getRecord();
if ( $record ){
echo '<img src="'.$record->display('image_url').'"/>';
}
}
Re: Displaying an uploaded image?

Posted:
Thu Jun 10, 2010 11:09 am
by librarymark
Wow - you are amazing! This:
- Code: Select all
function block__before_image_url_widget(){
$record =& Dataface_Application::getInstance()->getRecord();
if ( $record ){
echo '<img src="'.$record->display('image_url').'"width="400" />';
}
...worked a treat! Thanks again!
Re: Displaying an uploaded image?

Posted:
Mon Jul 19, 2010 3:08 am
by chichi
I need som ehelp on this, My list is not showing images instead it shows the path to the image.
chichi
Re: Displaying an uploaded image?

Posted:
Mon Jul 19, 2010 4:28 am
by chichi
application-delegate.php - I found it.
I found it and added this code to it but it shows the image only in the edit-part not in the view list:
- Code: Select all
function bild__htmlValue(&$record){ // bild is my field in the table
return '<img src="'.$record->display('bild').'" width="400"></img>';
}
function bild__renderCell(&$record){
return '<img src="'.$record->display('bild').'" width="50"></img>';
}
function block__before_bild_widget(){
$record =& Dataface_Application::getInstance()->getRecord();
if ( $record ){
echo '<img src="'.$record->display('bild').'"width="400" />';
}
}
One more thing:
Do I need to declare a class like this:
- Code: Select all
class tables_referenten { ...
referenten is my table-name (referenten =Referenten)
chichi