-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Hi,
There is an issue when using your module as a custom field for a FieldtypeFile/Image due to the way you are caching the oembed object.
In a custom field (e.g. video) of a FieldtypeFile/Image (gallery) $page is a reference to a dummy page created on the fly to get the field’s value stored in the db (not in the field_video table as one might expect but in the field_gallery one, with each value saved in a json in the filedata column).
So because $page is different between ___wakeupValue() and ___formatValue() it results in _oembedObj returning null.
I created a PR that solves this issue by using the same dummy page per file but unless Ryan approves / merges it this issue remains.
Another way to go is to make changes to your files but it's clearly not the best as it would result in unnecessary calls to get the oembed data (since it's there in the db):
In FieldtypeOembed.module, replace line 150 with:
$oembedObj = $page->get('_oembedObj' . $field->name);
if(!$oembedObj) {
$oembedObj = $this->getBlankValue($page, $field);
$oembedData = $this->fetch($value);
if(is_array($oembedData)) $oembedObj->setArray($oembedData);
$page->setQuietly('_oembedObj' . $field->name, $oembedObj); // if need be?
}
return $oembedObj;And in InputfieldOembed.module, replace line 43 with:
if(!$this->hasPage->id && $this->hasPage->status === Page::statusOn | Page::statusCorrupted) { // we're dealing with a dummy page
$preview = $this->oembedPreview($field->type->formatValue($this->hasPage, $fieldtype, $this->get("value")));
} else {
$preview = $this->oembedPreview($this->hasPage->getFormatted($field->name));
}