ImageSelector with Relative URL
Hello,
I ran into the "important note" on this issue: www.sitefinity.com/.../selecting_sitefinity_4_content_inside_widget_designers.aspx
Important Note: the value persisted in string mode is the full url to the image, including the host name. So if you are working in a development or staging environment, you might get a url that begins with http://localhost. Be sure to update your widget properties when deploying to production.
The rest of the setup for ImageField is similar to PageField, so it is omitted here. Please take a look at the sample project below for the complete implementation.
My question is is there any suggested code based work around so that we can store the relative image path instead of the full image path? Also is there a suggested SQL find/replace script I can run to fix this when moving from dev to production with already chosen content?
Hi Kunal,
Actually you can modify the saved value in the getValue method of the image field's script part (but that would be hacking of the default ImageField). An easier approach would be to use Slavo's Thumbnail selector, which saves guids in the database (rather than links) and is a lot better for this case than the ImageField. Here's you can find the image selector :
http://www.sitefinity.com/blogs/slavoingilizov/posts/11-02-11/creating_a_thumbnail_selector_for_news_items.aspx