简体   繁体   English

在cms admin中放大图像预览

[英]Larger preview of image in cms admin

I have a ModelAdmin which stores images among other things. 我有一个ModelAdmin ,它可以存储图像等。 I can do thumbnails up to a certain size and download them but is there a way to display a larger version of the image while in the CMS admin? 我可以将缩略图缩小到一定大小并下载它们,但是在CMS管理员中是否可以显示较大版本的图像?

I think if I used the UploadField.ss template and added some custom code in there to display it, it could work however it would then be displayed through the CMS. 我认为,如果我使用UploadField.ss模板并在其中添加一些自定义代码来显示它,则它可以工作,但是随后将通过CMS显示。 Does SilverStripe provide an easy way to do this? SilverStripe是否提供一种简便的方法?

You can set the height and width of the upload field preview like that 您可以像这样设置上传字段预览的高度和宽度

UploadField::create('Image', 'Bild')
  ->setPreviewMaxWidth(120)
  ->setPreviewMaxHeight(120)
  ->addExtraClass('big-preview');

But the container size seems hardcoded in css so you need to change that too 但是容器的大小似乎是用CSS硬编码的,因此您也需要更改它

.big-preview .ss-uploadfield .ss-uploadfield-item .ss-uploadfield-item-preview {
  height: 120px;
  line-height: 120px;
  width: 120px;
}

.big-preview .ss-uploadfield .ss-uploadfield-item .ss-uploadfield-item-info {
  margin-left: 135px;
}

I don't know if that's the best way to do it, cause it seems a little bit hacky, but it works. 我不知道这是否是最好的方法,因为它似乎有点怪异,但可以。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM