Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba

ImageDataObjectManager doesn't add images first time


Go to End


1174 Views

Avatar
MarijnKampf

Community Member, 176 Posts

10 August 2011 at 11:53pm

I'm experiencing an error with ImageDataObjectManager that I can't work out. I'm using the same code on my development server (Windows) and live server (*nix). Code works on dev server, but not on live server.

Using an ImageDataObjectManager to add photographs to a page. After choosing existing image(s) I click continue. In the Editing file 1 of 2 page the image isn't show. The image not present icon is shown in editor.

I expected it to be an issue with rights in the assets folder, but if I click on one of the images that failed to add, I can then select the image successfully using the Image selector in the popup and a thumbnail appears (on resizing the thumbnails, they are correctly re-generated).

For what it's worth uploading a file through ImageDataObjectManager doesn't work either. However, uploading through Files & Images with DOM does work on both dev and live without issues.

Any clue to what the solution could be is appreciated!

	static $has_many = array(
			//
			// snip
			//
		'Images' => 'ImageResource'
	);


	function getCMSFields() {
		$fields = parent::getCMSFields();
			//
			// snip
			//
    $fields->addFieldToTab("Root.Content.Photos", new ImageDataObjectManager(
			$this, // Controller
			'Images', // Source name
			'ImageResource', // Source class
			'Image', // File name on DataObject
			array(
				'Name' => 'Name',
				'Description' => 'Description',
				'Maker' => 'Maker',
				'Email' => 'Contact email (auto anti-spam)',
				'Rights' => 'Free to publish?'
			), // Headings
			'getCMSFields_forPopup'
		));
			//
			// snip
			//
		return $fields;
	}

<?php
class ImageResource extends DataObject {
	static $db = array (
		'Name' => 'Text',
		'Description' => 'Text',
		'Maker' => 'Text',
		'Email' => 'Text',
		'Rights' => 'Boolean'
	);

	static $has_one = array (
		'Image' => 'Image',
		'Species' => 'Species'
	);

	public function getCMSFields_forPopup()
	{
		return new FieldSet(
			new TextField('Name'),
			new TextareaField('Description'),
			new TextField('Maker'),
			new TextField('Email', 'Contact email (auto anti-spam)'),
			new CheckboxField('Rights','Free to publish?'),
			new FileUploadField('Image')
		);
	}

	function onBeforeWrite() {
		$this->Email = str_replace(array("@", "."), array("(at)", "(dot)"), $this->Email);
		parent::onBeforeWrite();
	}

}

Using latest versions of both DOM (commit: dc7bb4...) and uploadify (commit: 1254c6...)