3

I have item level fallback enabled and it works.

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>


<sites>
  <site name="shell">
    <patch:attribute name="enableItemLanguageFallback">true</patch:attribute>
    <!--<patch:attribute name="enableFieldLanguageFallback">true</patch:attribute>-->
  </site>
  <site name="DotCom">
    <patch:attribute name="enableItemLanguageFallback">true</patch:attribute>
    <!--<patch:attribute name="enableFieldLanguageFallback">true</patch:attribute>-->
  </site>
  <site name="DotNet">
    <patch:attribute name="enableItemLanguageFallback">true</patch:attribute>
    <!--<patch:attribute name="enableFieldLanguageFallback">true</patch:attribute>-->
  </site>
</sites>

<contentSearch>
  <configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
    <indexes>
      <index id="sitecore_master_index">
        <enableItemLanguageFallback>true</enableItemLanguageFallback>
        <!--<enableFieldLanguageFallback>true</enableFieldLanguageFallback>-->
      </index>
    </indexes>
  </configuration>
</contentSearch>
<contentSearch>
  <configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
    <indexes>
      <index id="sitecore_web_index">
        <enableItemLanguageFallback>true</enableItemLanguageFallback>
        <!--<enableFieldLanguageFallback>true</enableFieldLanguageFallback>-->
      </index>
    </indexes>
  </configuration>
</contentSearch>

On one particular template I have an SVG. When I switch languages, it generates a 404 in the content editor:

enter image description here

The fill text of the 404:

HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

Most likely causes:
The directory or file specified does not exist on the Web server.
The URL contains a typographical error.
A custom filter or module, such as URLScan, restricts access to the file.

Things you can try:
Create the content on the Web server.
Review the browser URL.
Create a tracing rule to track failed requests for this HTTP status code and 
see which module is calling SetStatus. For more information about creating a 
tracing rule for failed requests, click here.

Detailed Error Information:
Module     ManagedPipelineHandler
Notification       ExecuteRequestHandler
Handler    Sitecore.MediaRequestHandler
Error Code     0x00000000
Requested URL      http://local.blahblahblah.com:80/sitecore/shell/applications/-/media/672d4bfecbcc43bf9651d6103790b549.ashx?bc=white&db=master&h=128&la=es-mx&mw=640&thn=1&ts=20170724t1816095659&udi=1
Physical Path      C:\inetpub\wwwroot\local.blahblahblah.com\Website\sitecore\shell\applications\-\media\672d4bfecbcc43bf9651d6103790b549.ashx
Logon Method       Anonymous
Logon User     sitecore\Admin

More Information:
This error means that the file or directory does not exist on the server. 
Create the file or directory and try the request again.
View more information »

How come I dont just see the image/svg when I switch to Spanish. Why does it generate 404?

UPDATE

The template of the svg: /sitecore/templates/System/Media/Versioned/Image

  • If you switch back to the default language and navigate to the selected media item, what is its template type? – Zachary Kniebel Jul 24 '17 at 19:12
2

The Problem

I have most often seen this issue occur when using versioned media on multi-lingual sites.

If your media item is a versioned media item and you don't have a version for the Spanish language then when the field falls back it will try to point at the Spanish version of the item. Since the Spanish version doesn't exist, you would get a 404.

Note that, by default, Sitecore ships with all media items set to be unversioned. This is for sake of storage space.

Why is unversioned media the default?

Imagine the number of languages on your site is num_langs, the number of media items is num_media, and the average size of a media item is avg_media_size.

If all of the media on your site was versioned and you add a version for every language (so that media is never "not found") then the size of your media library would be:

SIZE_OF(MediaLibrary) = num_langs * num_media * avg_media_size

In contrast, if you use unversioned media then the size of your media library would be:

SIZE_OF(MediaLibrary) = num_media * avg_media_size

This means that if you used versioned media then the number of languages that you have becomes a coefficient for the size of your media library, in the worst case.

Why is versioned media supported if the storage difference is so dramatic?

While the it may seem like there is a pretty dramatic difference in storage when using versioned media vs unversioned media, the equations that we looked at were biased for unversioned media.

If your site makes effective use of versioned media then you will benefit from it greatly. This is because you will have avoided adding a separate image field for each language (if the instance of an image, PDF, video, or other media types is language-specific), and avoided having a separate media item for every language of the media. Additionally, you will be able to reduce your code and increase performance by simply rendering the field values for the context language (after checking for null on reference field types, of course). However, you need to make sure that versioned media is something that you really should use. If you don't have language-specific images then it's often a step too far.

When considering using versioned media, my typical recommendation is to add a custom Ribbon button to upload a versioned media item and to change an unversioned media item to a versioned media item and vice-versa. Then, you can keep the default as unversioned and decide on a case-by-case basis.

How to tell if unversioned media is being used

There are two ways to tell if you are using unversioned media:

  1. Check your configuration - not definitive but tells you the default
  2. Look at the item's template - tells you about the specific instance

The Media.UploadAsVersionableByDefault setting

Have a look at the Media.UploadAsVersionableByDefault setting. If true, all media items will be added as versioned, by default. Otherwise, they will be unversioned (Sitecore ships with unversioned as the default).

While this will tell you whether or not media is uploaded as versioned by default, it won't necessarily tell you that your item is versioned or unversioned. Regardless of the value of this setting, you can manually add or create custom buttons/tools to add both versioned and unversioned media.

Using the template path to determine versioned vs unversioned

You can tell if unversioned media is being used by looking at the template of your media item. For each media template, Sitecore includes both a versioned and an unversioned template that can be used.

The native versioned media templates live in the /sitecore/templates/System/Media/Versioned folder, while the /sitecore/templates/System/Media/Unversioned folder contains the native unversioned media templates. Each versioned template is associated with its unversioned template "mate" via configuration, in the /sitecore/mediaLibrary/mediaTypes section.

The following screenshot (from a clean Sitecore 8.1 site) shows a few examples of how Sitecore associates the versioned and unversioned templates:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.