1
votes

I have asked the following question at the Our Umbraco community site also, but I've had no luck there so far.

I've got a task where I need to manually add database records for a media image file, which is to appear in an Umbraco site for our client.

My SQL consists of:

  • Adding a record in umbracoNode for the image.
  • Adding a record in cmsContent
  • Adding a record in cmsContentXml
  • Adding records to cmsPropertyData for the image's umbracoFile, umbracoWidth, umbracoHeight, umbracoBytes, umbracoExtension

After executing the above, and logging into Umbraco, I can see the image in the Media area and all looks fine.

The problem is the call the @Model.MediaById() (in a Razor file) when I want to display that image - basically no image is displayed since the img 'src' attribute is not set.

I've stepped through the Umbraco code and found the problem. Basically when the code uses Lucene to search for the media (ExaminedBackendMedia.GetUmbracoMedia()), it does find the image file, however there are a number of fields missing for the SearchResult. For example, none of the "umbraco*" properties adde to cmsPropertyData appear in the fields collection. When I step through the code for another image (one that was added manually) I can see an extra 5 or so properties in the fields collection - including all the "umbraco*" properties.

So I can see that I have missing data here. Basically the SearchResult object is missing some fields. Can someone suggest what I may have missed please? Why is Lucene not picking up the "umbraco*" properties that I've added via SQL scripts?

1
If you republish all nodes, and then step thru the code, are the missing fields there for your manually added content? - E.J. Brennan
Yeah all the fields that I added to cmsPropertyData ("umbracoWidth" for example) are missing from SearchResult.Fields. This says to me that I've missed a step, since Lucene is not picking up these fields. - Jason Evans
Oh hold on, I just noticed you mentioned "republish all nodes". What is that process exactly? - Jason Evans
Right click on the root node in the content pane, and choose republish entire site; my thought was, if it showed up then, it means you need to refresh the cache after you add the items to the database manually. - E.J. Brennan
That looks to have worked mate :) I republished everything, and now the images have appeared. Many thanks. If you place that comment as an answer, I'm more then happy to mark it as the correct one. - Jason Evans

1 Answers

1
votes

You need to make sure that you republish the nodes, which will take them from the database entries that you created and put them into the XML cache that umbraco actually uses when serving up data.