A place for users and developers of the Xataface to discuss and receive support.
by sophistry » Mon Feb 02, 2009 6:34 pm
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
-
sophistry
-
- Posts: 27
- Joined: Mon May 19, 2008 11:20 am
by shannah » Mon Feb 02, 2009 10:06 pm
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.
-
shannah
-
- Posts: 4457
- Joined: Wed Dec 31, 1969 5:00 pm
by sophistry » Sun Mar 29, 2009 5:32 pm
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
-
sophistry
-
- Posts: 27
- Joined: Mon May 19, 2008 11:20 am
by shannah » Thu Apr 02, 2009 6:54 pm
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').'"/>'; }
-
shannah
-
- Posts: 4457
- Joined: Wed Dec 31, 1969 5:00 pm
by cwight27 » Tue May 05, 2009 6:53 pm
I attempted to piece this information in the post and it generated an error does anyone know the step by step procedure.
-
cwight27
-
- Posts: 10
- Joined: Mon Apr 27, 2009 6:43 pm
by fongchun » Tue May 05, 2009 11:47 pm
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.
-
fongchun
-
- Posts: 30
- Joined: Sun Aug 03, 2008 12:23 am
- Location: Vancouver, BC
by librarymark » Thu Jun 10, 2010 10:00 am
Is there a way to make the image show up on the list view and the edit view?
-
librarymark
-
- Posts: 4
- Joined: Thu Jun 10, 2010 9:59 am
by shannah » Thu Jun 10, 2010 10:06 am
Yes. Which are you having trouble with right now? The list view or the edit view?
-
shannah
-
- Posts: 4457
- Joined: Wed Dec 31, 1969 5:00 pm
by librarymark » Thu Jun 10, 2010 10:09 am
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>'; }
-
librarymark
-
- Posts: 4
- Joined: Thu Jun 10, 2010 9:59 am
by shannah » Thu Jun 10, 2010 10:27 am
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').'"/>'; }
-
shannah
-
- Posts: 4457
- Joined: Wed Dec 31, 1969 5:00 pm
by librarymark » Thu Jun 10, 2010 10:56 am
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>'; } }
?>
-
librarymark
-
- Posts: 4
- Joined: Thu Jun 10, 2010 9:59 am
by shannah » Thu Jun 10, 2010 11:01 am
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').'"/>'; } }
-
shannah
-
- Posts: 4457
- Joined: Wed Dec 31, 1969 5:00 pm
by librarymark » Thu Jun 10, 2010 11:09 am
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!
-
librarymark
-
- Posts: 4
- Joined: Thu Jun 10, 2010 9:59 am
by chichi » Mon Jul 19, 2010 3:08 am
I need som ehelp on this, My list is not showing images instead it shows the path to the image.
chichi
Last edited by chichi on Mon Jul 19, 2010 5:06 am, edited 1 time in total.
-
chichi
-
- Posts: 28
- Joined: Fri Jul 09, 2010 3:05 am
by chichi » Mon Jul 19, 2010 4:28 am
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
-
chichi
-
- Posts: 28
- Joined: Fri Jul 09, 2010 3:05 am
Return to Xataface Users
Who is online
Users browsing this forum: No registered users and 7 guests
|