An eye for details… changing the ImageUrl for migrated lists

Migrating from SharePoint 2007 to SharePoint 2013 can cause all kind of headaches but this post is not about those headaches. It’s about details, or better… having an eye for details. Ever noticed that after you migrate a site to SharePoint 2013 and you complete the actual visual upgrade to SharePoint 2013 mode, the list icons which are used, are not the fancy list icons which you get when you create a new list or library in SharePoint 2013? The icons for migrated lists and libraries are still the old icons from the early days of SharePoint 2007.

ImageUrl - 1

The icon for a list or library is stored in the ImageUrl property of a list and this property points to a gif or png in the “/_layouts/images/” folder for migrated lists. When you create a new list in SharePoint 2013, the value of the property points to “/_layouts/15/images”. Furthermore, if you compare for instance a migrated document library with a new document library, you notice that the value of the property differs, not only in the location where the icon is displayed from, but also the type of file. For instance, a simple document library.

  • Migrated document library : /_layouts/images/itdl.gif
  • New document library : /_layouts/15/images/itdl.png?rev=23

While I can imagine that a lot of people really don’t see any issue with this and don’t care how those icons look like, I don’t like loose ends. If you migrate an environment, you might as well get it done completely and replace the list icons with new versions as well and get the following result in the end.

ImageUrl - 2

Admit it, this looks much better than those old school icons. It’s a small detail, but it just makes more sense. If you have a smart user who actually cares about the environment, the question why new lists have different icons than existing lists, will eventually pop up anyway and if you tell them that this the result of the migration, the next question will be whether you can change them to resemble the new lists. Show your customers or users you have an eye for detail and do it proactively.

Changing these icons can be done very easily using PowerShell. The only thing you need is a mapping between the old and new icon.

I created a script which replaces all icons for lists and libraries. In this script, a mapping is done for the mostpart of the icons which are used. It might not be the complete list, but feel free to add missing icons. There are some scripts out there which replace icons, not based on a mapping but just replace all .gif icons with .png’s. However, there are some icons which don’t have .png counterparts. So, if you replace those, your list icon will be broken.

    Replace old SP2007 list icons with new icons

    Replace old SP2007 list icons with new icons.

    File Name: Replace-ListImageUrl.ps1
    Author   : Bart Kuppens
    Version  : 1.0

# Switch to STA mode
$host.Runspace.ThreadOptions = "ReuseThread"


# Load the SharePoint PowerShell snapin if needed
if ((Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null)
    Write-Output "Loading SharePoint Snap-in..."
    Add-PSSnapin Microsoft.SharePoint.PowerShell

function Get-NewImageUrl([string]$ImageUrl)
    $newImageUrl = [string]::Empty
    switch ($ImageUrl.ToLower())
        "/_layouts/images/itil.gif" { $newImageUrl = "/_layouts/15/images/itil.png?rev=23"; break }
        "/_layouts/images/itil.png" { $newImageUrl = "/_layouts/15/images/itil.png?rev=23"; break }
        "/_layouts/images/itdatash.gif" { $newImageUrl = "/_layouts/15/images/itdatash.png?rev=23"; break}
        "/_layouts/images/itwfh.png" { $newImageUrl = "/_layouts/15/images/itwfh.png?rev=23"; break}
        "/_layouts/images/users.gif" { $newImageUrl = "/_layouts/15/images/users.gif?rev=23"; break}
        "/_layouts/images/itdisc.gif" { $newImageUrl = "/_layouts/15/images/itdisc.png?rev=23"; break}
        "/_layouts/images/itevent.gif" { $newImageUrl = "/_layouts/15/images/itevent.png?rev=23"; break}
        "/_layouts/images/itcommnt.gif" { $newImageUrl = "/_layouts/15/images/itcommnt.gif?rev=23"; break}
        "/_layouts/images/itdl.gif" { $newImageUrl = "/_layouts/15/images/itdl.png?rev=23"; break}
        "/_layouts/images/itdl.png" { $newImageUrl = "/_layouts/15/images/itdl.png?rev=23"; break}
        "/_layouts/images/itobject.gif" { $newImageUrl = "/_layouts/15/images/itobject.png?rev=23"; break}
        "/_layouts/images/itgen.gif" { $newImageUrl = "/_layouts/15/images/itgen.png?rev=23"; break}
        "/_layouts/images/itgen.png" { $newImageUrl = "/_layouts/15/images/itgen.png?rev=23"; break}
        "/_layouts/images/itsurvey.gif" { $newImageUrl = "/_layouts/15/images/itsurvey.png?rev=23"; break}
        "/_layouts/images/icxddoc.gif" { $newImageUrl = "/_layouts/15/images/ICXDDOC.GIF?rev=23"; break}
        "/_layouts/images/ittxtbox.gif" { $newImageUrl = "/_layouts/15/images/ittxtbox.gif?rev=23"; break}
        "/_layouts/images/ittask.gif" { $newImageUrl = "/_layouts/15/images/ittask.png?rev=23"; break}
        "/_layouts/images/itfl.gif" { $newImageUrl = "/_layouts/15/images/itfl.png?rev=23"; break}
        "/_layouts/images/itcontct.gif" { $newImageUrl = "/_layouts/15/images/itcontct.png?rev=23"; break}                                                        
        "/_layouts/images/itthgbrg.gif" { $newImageUrl = "/_layouts/15/images/itthgbrg.png?rev=23"; break} 
        "/_layouts/images/itposts.gif" { $newImageUrl = "/_layouts/15/images/itposts.gif?rev=23"; break}
        "/_layouts/images/itlink.gif" { $newImageUrl = "/_layouts/15/images/itlink.png?rev=23"; break}
        "/_layouts/images/itcat.gif" { $newImageUrl = "/_layouts/15/images/itcat.gif?rev=23"; break}
        "/_layouts/images/itagnda.gif" { $newImageUrl = "/_layouts/15/images/itagnda.png?rev=23"; break}
        "/_layouts/images/itann.gif" { $newImageUrl = "/_layouts/15/images/itann.png?rev=23"; break}
    return $newImageUrl

$sites = Get-SPSite -Limit All
foreach ($site in $sites)
        $webs = $site.AllWebs
        foreach ($web in $webs)
                Write-Host -ForegroundColor Yellow $web.Url
                $lists = $web.Lists
                foreach ($list in $lists)
                    Write-Host "   $($list.Title)"
                    $ImageUrl = Get-NewImageUrl -ImageUrl $list.ImageUrl
                    if (![String]::IsNullOrEmpty($ImageUrl))
                        Write-Host -ForegroundColor DarkGreen "      OldImage: $($list.ImageUrl) ; NewImage: $ImageUrl"
                        $list.ImageUrl = $ImageUrl
                        Write-Host -ForegroundColor Red "      Image '$($list.ImageUrl)' not replaced"
            catch {}
    catch {}

You can find this script in my PowerShell repository on GitHub

By Bart

Bart is a certified SharePoint consultant / architect at CTG Belgium NV with a broad professional experience in IT, a background in software development with a specialisation in Microsoft products and technologies and a solid knowledge and experience in Microsoft SharePoint Products and Technologies. He started as a COBOL developer on a mainframe environment and grew into software development for Windows platforms. Participated in projects varying from migrations of existing applications to development of Web applications and Windows applications. Became fascinated by the SharePoint 2007 platform and strongly believed in the added business value of this platform. Is since then fully committed to SharePoint and focuses on SharePoint implementations, migrations, integrations, design and coaching. Stays on top of new developments within the SharePoint technology stack and related technologies.

%d bloggers like this: