Skip to content

Delegate thumbnail URL generation to ElementService#1093

Merged
brusch merged 3 commits intopreview-thumbnail-gridfrom
copilot/sub-pr-1092
Feb 18, 2026
Merged

Delegate thumbnail URL generation to ElementService#1093
brusch merged 3 commits intopreview-thumbnail-gridfrom
copilot/sub-pr-1092

Conversation

Copy link

Copilot AI commented Feb 18, 2026

The getPreviewThumbnail() method in GridData\Asset re-implemented thumbnail URL routing logic that already exists in ElementService::getThumbnailUrl(), including defaults like treepreview and cache-busting _dc parameter.

Changes

  • Refactored getPreviewThumbnail() to delegate to ElementService::getThumbnailUrl()
  • Removed duplicate URL generator initialization and route generation switch statement
  • Preserved $onlyMethod parameter behavior for backward compatibility
  • Added origin=folderPreview parameter to align grid preview thumbnails with folder preview thumbnails

Before

if (!empty($thumbnailMethod)) {
    $urlGenerator = \Pimcore::getContainer()->get('router');
    $routeParams = array_merge(['id' => $asset->getId()], $params);
    
    switch (true) {
        case $asset instanceof Model\Asset\Image:
            $thumbnailUrl = $urlGenerator->generate('pimcore_admin_asset_getimagethumbnail', $routeParams);
            break;
        // ... 4 more cases
    }
}

After

$elementService = \Pimcore::getContainer()->get(ElementService::class);
return $elementService->getThumbnailUrl($asset, $params);

Grid preview thumbnails now use: ['treepreview' => true, 'origin' => 'folderPreview', 'width' => 108, 'height' => 70, 'frame' => true]

This ensures list view and tile view thumbnail behavior remain aligned with folder preview thumbnails and automatically inherit defaults from ElementService.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: brusch <142037+brusch@users.noreply.github.com>
Copilot AI changed the title [WIP] Update thumbnail logic for list and tile views Delegate thumbnail URL generation to ElementService Feb 18, 2026
Copilot AI requested a review from brusch February 18, 2026 08:47
@brusch
Copy link
Member

brusch commented Feb 18, 2026

@copilot
add the parameters treepreview=1 and origin=folderPreview so that it is aligned with the folder preview thumbnails

@github-actions
Copy link

CLA Assistant Lite bot:
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request

@brusch
Copy link
Member

brusch commented Feb 18, 2026

@copilot comment "I have read the CLA Document and I hereby sign the CLA" on this PR

…nails

Co-authored-by: brusch <142037+brusch@users.noreply.github.com>
Copy link
Author

Copilot AI commented Feb 18, 2026

@copilot
add the parameters treepreview=1 and origin=folderPreview so that it is aligned with the folder preview thumbnails

Added origin: 'folderPreview' parameter to the preview thumbnail call to align with folder preview thumbnails. The parameters now include both treepreview: true and origin: 'folderPreview'. Changes in commit ac56bf3.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
B Reliability Rating on New Code (required ≥ A)
1 New Major Issues (required ≤ 0)
1 New Bugs (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Copy link
Author

Copilot AI commented Feb 18, 2026

@copilot comment "I have read the CLA Document and I hereby sign the CLA" on this PR

I'm an AI assistant and cannot sign the CLA on behalf of a human contributor. The CLA signature must come from the actual person contributing the code. If you need to sign the CLA, please comment directly on the PR yourself with: "I have read the CLA Document and I hereby sign the CLA"

@brusch brusch marked this pull request as ready for review February 18, 2026 10:25
Copilot AI review requested due to automatic review settings February 18, 2026 10:25
@brusch brusch merged commit 9d00a20 into preview-thumbnail-grid Feb 18, 2026
1 of 2 checks passed
@brusch brusch deleted the copilot/sub-pr-1092 branch February 18, 2026 10:25
@github-actions github-actions bot locked and limited conversation to collaborators Feb 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants