Noticed there was an issue with support for media items that utilize remote stream wrappers to generate the content. I took a deep dive and found a possible solution, but we need to have a discussion on whether it makes sense to have it be used under the viewElements method for the PDFPreviewFormatter.

Also noticed that there was some discussion about this problem on the Drupal 7 version of this module, maybe we can find a better solution by looking at that one.

Comments

marioangulo created an issue. See original summary.

marioangulo’s picture

Version: 8.x-1.0-rc1 » 8.x-1.x-dev
marioangulo’s picture

StatusFileSize
new1.43 KB

Here is a patch for this issue.

marioangulo’s picture

Status: Active » Needs review
marioangulo’s picture

Assigned: marioangulo » Unassigned
mstrelan’s picture

Title: Remote Url Support » Remote URL Support
Status: Needs review » Needs work
rithesh bk’s picture

Assigned: Unassigned » rithesh bk

currently i am working on it ............

rithesh bk’s picture

Assigned: rithesh bk » Unassigned
Status: Needs work » Needs review
StatusFileSize
new1.79 KB

Please find the updated patch ......

mstrelan’s picture

Status: Needs review » Needs work

Actually this code should be called from PDFPreviewGenerator::createPDFPreview(). The existing filemtime() checks in PDFPreviewGenerator::getPDFPreview() will be problematic. I guess we could do something like this:

  public function getPDFPreview(File $file) {
    $destination_uri = $this->getDestinationURI($file);
    // Check if a preview already exists.
    if (file_exists($destination_uri)) {
      if (UrlHelper::isExternal($file->getFileUri())) {
        return $destination_uri;
      }
      // Do the other mtime stuff
      // ...
    }
    if ($this->createPDFPreview($file, $destination_uri)) {
      return $destination_uri;
    }
  }

However that means we'll never generate an updated preview if the source PDF changes. Not sure how much we can do about that as I really don't want to download the PDF every time the preview is requested.

We also need to extend PDFPreviewGeneratorTest::testGetDestinationUri() to handle remote stream wrappers.

mstrelan’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
mstrelan’s picture