Problem/Motivation
Validation of the Flickr Embed Code / URL isn't working
Steps to reproduce
Create a new Flickr Media Entity, type any random text in the "Flickr URL" field, and click Save.
It creates the new entity without any complaint, but the thumbnail is just the default Flickr logo.
Proposed resolution
The problem is in function validate() in FlickrEmbedCodeConstraintValidator.php, The current code leaves $data as an empty string, but it should be the text from the "Flickr URL" field, for validation:
$data = '';
if (is_string($value)) {
$data = $value;
}
elseif ($value instanceof FieldItemInterface) {
$class = get_class($value);
$property = $class::mainPropertyName();
if ($property) {
$data = $value->{$property};
}
}
I don't understand how that is supposed to work, but if I replace it with code copied from the validator from OEMbed:
$media = $value->getEntity();
$source = $media->getSource();
$data = $source->getSourceFieldValue($media);
Then $data is correctly set to the value the user entered, so it can be checked by rest of the validate() function.
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
anandhi karnan commentedHere is the patch which fixed the validation of Flickr Embed Code. Please review the attached patch.
Comment #3
anandhi karnan commented