【问题标题】:Datatables: Upload - Display Thumbnail of PDF数据表:上传 - 显示 PDF 的缩略图
【发布时间】:2019-01-05 11:51:40
【问题描述】:

我正在使用 Datatables 中的标准上传功能。图像正确显示缩略图。如何获取上传的 PDF 以显示缩略图?目前它只显示一个小的损坏文件图标。

来自 HTML:

{ "className": "dt-right", data: "image",
            render: function ( file_id ) {
                return file_id ?
                    '<img src="'+editor.file( 'files', file_id ).web_path+'" class="img-circle" width="40" height="40"/>' :
                    null;
            },
            defaultContent: "No image",
            title: "image"
        }

来自 PHP:

Field::inst( 'image' )
->setFormatter( 'Format::ifEmpty', null )
->upload( Upload::inst( $_SERVER['DOCUMENT_ROOT'].'/upload/__ID__.__EXTN__' )
    ->db( 'files', 'id', array(
        'filename'    => Upload::DB_FILE_NAME,
        'filesize'    => Upload::DB_FILE_SIZE,
        'web_path'    => Upload::DB_WEB_PATH,
        'system_path' => Upload::DB_SYSTEM_PATH
    ) )
    ->validator( function ( $file ) {
        return$file['size'] >= 2000000 ?
            "Files must be smaller than 2M" :
            null;
    } )
    ->allowedExtensions( array( 'png', 'jpg', 'gif', 'pdf' ), "Please upload an image" )
)

【问题讨论】:

    标签: pdf datatables thumbnails


    【解决方案1】:

    您可以使用像Post2Preview 这样的缩略图服务,它支持数百种文件类型。免责声明:我为 Post2Preview 工作

    【讨论】:

      猜你喜欢
      • 2011-02-21
      • 2016-05-24
      • 2012-03-13
      • 1970-01-01
      • 2017-08-29
      • 2016-05-10
      • 1970-01-01
      • 2012-11-19
      • 2014-02-16
      相关资源
      最近更新 更多