Skip to content
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

Thumbnails in CMS File system not showing up in Subfolders #1459

Closed
2 tasks done
draghu9 opened this issue May 10, 2024 · 3 comments
Closed
2 tasks done

Thumbnails in CMS File system not showing up in Subfolders #1459

draghu9 opened this issue May 10, 2024 · 3 comments

Comments

@draghu9
Copy link

draghu9 commented May 10, 2024

Module version(s) affected

2.2.0

Description

Silverstripe Framework version 5.2.6
Asset admin version 2.2.0
Operating in clean Silverstripe install with no customizations

Uploading images in the CMS Files system is working but thumbnails are not showing up upon Publish. This is happening at the sub directory level. Example If we create a folder structure in Files as Files->Level1->Level2->Level3 and Upload an image at directory Level 3 and publish the thumbnail is missing.

I have checked the image src and the problem seems to be missing forward slashes (/) that separates the sub directories. Adding the forward slashes in the path via Inspect Element showed me the thumbnail.

Following GIF should represent what I mentioned above.

SS_Thumbnail

How to reproduce

  1. Login to CMS running on Silverstripe framework 5.2.6 and Admin-Assets 2.2.0
  2. Navigate to Files section from Left hand menu
  3. Create nested sub-directories. Example Files->Level1Directory->Level2Directory->Level3Directory
  4. Upload an image in Level3Directory
  5. Publish

Possible Solution

Navigating through the code I found there is a function called generateThumbnailLink(AssetContainer $file, $width, $height, $graceful = false) in ThumbnailGenerator.php file.

$result = $this->generateLink($thumbnail); gives the missformed thumbnail URL with all backslashes
adding str_replace("\","/",$result); seems to resolve the issue.

Additional Context

No response

Validations

  • Check that there isn't already an issue that reports the same bug
  • Double check that your reproduction steps work in a fresh installation of silverstripe/installer (with any code examples you've provided)

PRs

@emteknetnz
Copy link
Member

emteknetnz commented May 13, 2024

I'm unable to replicate this.

Is your webserver running Windows?

Could you try updating vendor/silverstripe/assets/src/Flysystem/PublicAssetAdadter::getPublicUrl() to the following:

    public function getPublicUrl($path)
    {
        $path = Convert::slashes($path, '/'); // this line is new
        return Controller::join_links(Director::baseURL(), $this->parentUrlPrefix, $path);
    }

And let me know if that fixes the issue?

@draghu9
Copy link
Author

draghu9 commented May 14, 2024

I have done the changes as you mentioned, and it seems to have fixed the issue. Also Yes, my web server is running on Windows

@GuySartorelli
Copy link
Member

PR merged. This will be automatically tagged by GitHub actions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants