- π³πΏNew Zealand quietone
I found a duplicate of this problem, π Repeated file_usages when listing them Needs work . It is later but it has more discussion and patches.
I am closing this as a duplicate and moving credit.
When one image is used in two nodes, the files management page (admin/content/files) shows as expected "Used in 2 places". However the file usage detail view (admin/content/files/usage/[fid]) shows four lines.
Here is some code to reproduce the issue (if you use the same file in 2 nodes, you will have 4 rows on the file usage page; if you use the same file in 3 nodes, you will have 9 rows on the file usage page; if you use the same file in 4 nodes, you will have 16 rows on the file usage page, etc.):
$file = \Drupal\file\Entity\File::create([
'uri' => 'public://test.png',
]);
$file->save();
$node = \Drupal\node\Entity\Node::create([
'type' => 'article',
'title' => 'Test 1',
'field_image' => ['target_id' => $file->id()],
]);
$node->save();
$node = \Drupal\node\Entity\Node::create([
'type' => 'article',
'title' => 'Test 2',
'field_image' => ['target_id' => $file->id()],
]);
$node->save();
drupal_flush_all_caches();
Add a 'distinct' to the file usage view.
h3 id="summary-ui-changes">User interface changes
None. Using a different default configuration value.
none
none
Closed: duplicate
9.5
Last updated
The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
I found a duplicate of this problem, π Repeated file_usages when listing them Needs work . It is later but it has more discussion and patches.
I am closing this as a duplicate and moving credit.