How can I access the images folder from code behind - image

I have an image on the images folder of a SharePoint 2013 site. I want to access this folder (and this image) to load it on a carousel, but I don't know where is it and how I can access to it.
Can anyone helps me? Thanks!
I upload an screenshot, hope it helps.

We can get the image URL like below:
Then use the URL in to show the image.
<img src="/sites/team/PublishingImages/Capture32.PNG"/>
If you want to get image using C# in Server, we can get images library and get all list items.
using (SPSite site = new SPSite("http://sp2013/sites/team"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["Images"];
foreach (SPListItem item in list.Items)
{
Console.WriteLine(item.File.ServerRelativeUrl);
}
}
}

Related

Uploading images to Windows Server and making them available publicly

I am trying to upload images in my windows server VM "hosted on-premise" and make these images available publicly like www.example.com/imageFolder/cat.png.
This VM has IIS enabled (I am not sure if IIS is related here) and it is assigned a URL and available publicly.
Aside from any programming languages or frameworks, I just want to know if storing the image in the server and making it available via a link is possible? If so, how can I achieve it?
To clarify further:
I believe what I want is very simple and tedious.
Consider the following workflow:
Run an API that has end points to receive images on the server.
Store the messages in the server.
Return the link that points to the picture.
I want to know the procedure from the windows server side like
Do I need to set certain properties on the folder where I will store the images?
Do I need to add a site to show the images back to the user?
I am a developer and I am new to the Windows Server & IIS so I may not have all the fundamentals.
I made a sample by using ASP.NET MVC5. You can follow this article to upload image in MVC5 application.
Upload Images on Server Folder Using ASP.NET MVC
Then, I do some changes so that it can display the url of images..
[HttpPost]
public ActionResult Upload(HttpPostedFileBase file)
{
Uri requestUri = HttpContext.Request.Url;
string baseUrl = requestUri.Scheme + Uri.SchemeDelimiter + requestUri.Host + (requestUri.IsDefaultPort ? "" : ":" + requestUri.Port);
if (ModelState.IsValid)
{
try
{
if (file != null)
{
string path = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(file.FileName));
file.SaveAs(path);
}
string link = baseUrl + "/Images/" + file.FileName;
ViewBag.FileStatus = "File uploaded successfully.";
//Return the url of image
ViewBag.FileLink = link;
}
catch (Exception e)
{
ViewBag.FileStatus = "Error while file uploading. Error message is "+e.Message;
}
}
return View("Index");
}
Index.cshtml add this to show url.
<div class="col-md-offset-2 col-md-10 text-success">
#ViewBag.FileLink
</div>
Don't forget to add a folder named Images to store images. After publishing, you also need to add it in published folder, otherwise error message will show that cannot find folder.
It works well.

Flutter Workflow for saving & retrieving images

I am trying to build an app where the user can add images from Image Picker, then save it in a Provider as well as in Firebase. For retrieving it should be the other way around: Get it from Firebase and then store it in my Provider.
(ignore the Firebase part, for now I only want to store the images in a Provider, but it should be correctly set up, so I can add the Firebase support later)
The problem is that I am quite new to Flutter and I am not how to start here, because there are so many ways to load images in Flutter. From the ImagePicker I retrieve a File. What is the correct way to store this in a Provider so I can load it in another screen?
I know this is quite a genreal question but I hope some one can shed some light in the dark for me here :D Let me know if you need any more info.
I already setup a ChangeNotifier:
class MemoryImageProvider extends ChangeNotifier {
String path = '';
setImage(String path) {
path = path;
notifyListeners();
}
}

Save image from webservice call in in local PCL folder Xamarin Forms

I have looked for many examples of this and I believe they are trying to do something different than what want to do.
I have a set of images stored a folder in my pcl. See Image attached.
PCL Image
Currently I have those images set to embedded resource and they all display in my List View when their name is called. However if an update is made on the server like an image is changed or replaced or added I would like the new image to get saved in the AllImages folder as shown in the image. Is this possible? I've seen a lot of people doing separate dependencies to store the images in the platforms resources/ drawable folder but I don't want I don't want to do that. If i have to change where i am storing my images I can do that as well, but I do need to be able to store the images from the server on my app locally.
I currently have a class dedicated to embedded images, so it would be nice to do it this, but I am not married to the idea.
[ContentProperty("ResourceID")]
public class EmbeddedImage : IMarkupExtension
{
public string ResourceID { get; set; }
public object ProvideValue(IServiceProvider serviceProvider)
{
if (String.IsNullOrWhiteSpace(ResourceID))
return null;
return ImageSource.FromResource(ResourceID);
}
}

Attach image using Twitter Share link

Is it possible to attach an image to a tweet using the Twitter share link?
I'm using the following url to tweet but I can't find away to attach an image. The tweet has a link to the image but I want it attached to the tweet so someone can view the image while reading the tweet.
https://twitter.com/intent/tweet?hashtags=MyTag&url=http%3A%2F%2Ftest.com%2Fimage.png
Or would have to use the twitter api?
I would recommend using https://tweetinvi.codeplex.com/documentation which you can programmer directly with twitter.
// Publish with media
byte[] file = File.ReadAllBytes(filePath);
var tweet = Tweet.CreateTweetWithMedia("I love tweetinvi", file);
var imageURL = tweet.Entities.Medias.First().MediaURL;
// Publish with geo information
var tweet = Tweet.CreateTweet("Hello guys");
tweet.PublishWithGeo(-54.73, -64.2);
// Retweet
tweet.PublishRetweet();
I do not believe it is possible to upload media through the share link. Probably, a security decision by Twitter.
I suggest you try the twitpic API.

Webbrowser windows phone don't show an image

In my windows phone application, i'm using a webbrowser to render a HTML like this
private void webBrowserHTML_Loaded(object sender, RoutedEventArgs e)
{
WebBrowser web = sender as WebBrowser;
string description = web.DataContext.ToString();
web.NavigateToString(description);
}
My problem is i have html code that show an image in the variable description:
<img width=\"220\" class=\"logo\" alt=\"3950\" src=\"bandeau3950.png\" />
I put the image in the same folder with my code, but the image is not shown in the application.
Any solution please?
Solution 1
Use Base64 image uri format so that image is defined as part of html. You can use online conversion tools, like http://webcodertools.com/imagetobase64converter
Solution 2
Copy all required images to isolated storage folder. It can be done during app start up.
http://msdn.microsoft.com/en-us/library/ff431811%28VS.92%29.aspx
When html string is received save it to the same isolated storage as index.html
Do Navigate(new Uri("folder/index.html", UriKind.Relative))
In this case browser will be able to show images since your page and images in the same isolated storage folder.

Resources