Could not compute value for ComputedIndexField: sizerange for indexable

If during indexing you can find the following exception in Crawling.log:

Exception in Crawling.log

It means that probably some of your media items have a wrong values

Wrong value in a size field

Now, you have a difficult choice to make

If you chose to manually solve the problem, you can finish reading here.

Below you can find a ugly Powershell script that will do job automatically and generate at the end report about changes.

#
# Fix value '123 x 123' in Size field to the proper image size (bytes).
# Author: Robert Senktas
#
$sitecorePath = "master:/sitecore/media library"
$processedItems = Get-ChildItem -Path $sitecorePath -Recurse | ForEach-Object {
if ( $_.Size -match "x" ) {
$mediaItem = New-Object "Sitecore.Data.Items.MediaItem" $_
[Sitecore.Resources.Media.Media] $media = [Sitecore.Resources.Media.MediaManager]::GetMedia($mediaItem);
$stream = $media.GetStream()
$reportItem = [PSCustomObject]@{
ID = $_.ID
Path = $_.Paths.Path
Size = $_.Size
Length = $stream.Length
}
$_.Editing.BeginEdit()
$_["Size"] = $stream.Length
$_.Editing.EndEdit()
$_ | Publish-Item -PublishMode SingleItem -Verbose
return $reportItem
}
}
# Generate a report
Import-Function -Name ConvertTo-Xlsx
[byte[]]$outobject = $processedItems |
Select-Object -Property ID, Path, Size, Length |
ConvertTo-Xlsx
Out-Download -Name "report-change-image-size-.xlsx" -InputObject $outobject

Below the report.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.