21491 Posts in 5783 Topics by 2621 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 520 Views |
-
Images not showing up in Uploadfields Filebrowser

18 October 2012 at 7:00am Last edited: 18 October 2012 7:20am
Hello,
in multiple projects we extend the Image Class to add some Fields like "Caption" etc.
class CustomImage extends Image{
//add fields, override getCMSFields() etc.
}Now on a PageType which has many of those CustomImages those are managed with an uploadField
$has_many = array('CustomImages' => 'CustomImage')
$fields->addFieldToTab("Root.Main", new UploadField('CustomImages', 'Custom Images'), 'Content');
This works fine and Images upload via the uploadfield get the ClassName "CustomImage" in the "File" tab.
Problem:
When browsing for files to add, instead of uploading them directly, only Files with ClassName "CustomImage" show up.
Files uploaded in the Files-section however got the default ClassName "Image" and are not showing up within folders.Is there any way to use my custom Image type while still being able to add Images in the uploadfield via the Browser which
were added previously in the Files-section?Merci d'advance
Cheers
Max
-
Re: Images not showing up in Uploadfields Filebrowser

19 October 2012 at 12:26pm
It's better to use $many_many for linking to multiple images, otherwise it's impossible for an image to be linked in more than one place, which runs counter to the way the asset library is used elsewhere.
If you do use $has_many, make sure that you have added the relevant $has_one to Image.
-
Re: Images not showing up in Uploadfields Filebrowser

22 October 2012 at 6:54am
true.
Nevertheless i solved my actual problem by not extending image directly
(which might not be such a good idea at all, as it messes up the classnames in the "File" table)
but using the DataExtension Class:class ImageExtension extends DataExtension
{static $db = array(
'Alt' => 'Varchar'
);public function updateCMSFields(FieldList $fields) {
$fields->addFieldToTab('Root.Main', new TextField('Alt', 'Alt'), 'Name');
}}
Object::add_extension('Image', 'ImageExtension');
This way i could have an extra Alt-Text Field directly on the Image, which allows me to manage it using the uploadfield without the need for an additional dataobject and a gridfied...
-
Re: Images not showing up in Uploadfields Filebrowser

16 November 2012 at 6:03pm
I'm having the same issue, slightly different, because I want to use $gd image manipulation functions within my extension.
Right now I have:class CustomImage extends Image {
function generateProfileImage($gd) {
$gd->setQuality(80);
return $gd->resizeByWidth(110);
}
}I don't think I will be able to use $gd functions if I change this to extend DataExtension...
Does anyone know a way to get UploadField to query files with class name CustomImage AND Image?
| 520 Views | ||
|
Page:
1
|
Go to Top |



