-
-
Notifications
You must be signed in to change notification settings - Fork 494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sonata_media_type widget issue #974
Comments
I got the same problem, do you find a solution to this? |
@ahmetakbn i think you have the same problem, am I right? |
@OskarStark yes, the issue I was talking about is exactly this. |
I hotfixed it by extending ImageProvider with this code: namespace AppBundle\Provider;
use Sonata\MediaBundle\Model\MediaInterface;
use Sonata\MediaBundle\Provider\ImageProvider as SonataImageProvider;
class ImageProvider extends SonataImageProvider
{
protected function doTransform(MediaInterface $media)
{
// Check if the entity is new
if (!is_null($media->getId())) {
// Prevent the file from being erased
$media->resetBinaryContent();
// Prevent the provider reference from being erased
$media->setProviderReference($media->getPreviousProviderReference());
return;
} else {
// If new media, nothing special to do
return parent::doTransform($media);
}
}
} And adding this in parameters:
It works in my use case but it is sure to fail with new_on_update param set to false on the form. |
Hi all. I got the same problem. Thanks you! |
I have the same problem! sonata-project/media-bundle 3.5.0 |
Can you provide a PR with a fix @storke ? |
@core23 Has I said, this fix works just for my use case and breaks the new_on_update option. I didn't find a better solution so I will not PR it, maybe it could inspire someone to correct it? |
Close because #1273 is just the same issue with a better explanation and more comments. If this issue is completely different ping me to reopen, otherwise, lets centralize discussions |
Hi,
I encountered a strange issue. I have an entity that has a Media object relation and in the admin form for that entity I am using a sonata_media_type form element to render the data field. If I select a new image and update the parent entity, it works as expected, i.e, a new Media object is created and persisted, but then, if I replace that image with a new one, a new Media object is created (as expected) but the old Media object's image is also updated to the new image that was just uploaded, therefore ending up with two Media objects that look the same (although with different names).
Have any of you came across this problem before?
Symfony 2.8, with the master versions of Sonata Admin and Sonata Media.
Thank you in advance.
Best regards,
Filipe
The text was updated successfully, but these errors were encountered: