how to display image with with Projection in Orchard 1.7.
i have try but not able to get image its sow me ID with select html layout and custom display html.
can some on help me to get image with orchard projection/query
==Updated Post
I have one Query to select all company name (input text) , detail (input text) and company image, i want to show a list of all company name with image thumb on front site with projection and query ...list is coming but how to get image that is the problem.
thanks
If you're using ImagePart you should be able to access to MediaPart. MediaPart has FolderPath and FileName property. Just do something like this: Image.As.FolderPath to access to it in your shape.
If you are not using ImagePart, be more specific (e.g. showing some code)
Related
In my web content structure, I have a Document and Media type field so that users can select an image. In the web content template, I want to get the selected image's description so that I can fill in the alt text for the image.
How do I go about doing getting the description information of that selected image in the template?
You can get fields like description, you need to first get the image ID. Then you'll use the DLFileEntryLocalServiceUtil to get the file. Once you get the file, you can call the function to get the description.
<#assign imgID = Image.getData()?string?split("/")[5]?split("?")[0]>
<#assign fileEntry = staticUtil["com.liferay.portlet.documentlibrary.service.DLFileEntryLocalServiceUtil"]>
<#assign file=fileEntry.getFileEntryByUuidAndGroupId(imgID, groupId) >
${file.getDescription()}
You can get the other metadata of the document/image by calling one of the other functions for the DLFileEntryModel.
Is it possible to remove/disable the selection of the Image Rendition when selecting a picture in a custom content type?
Any User/Contributer should not be able to choose the image Rendition because it happens programmatically in the Display Template. The Picture must always be choosen as Full Size Image!
Has anyone an idea how i can set this up?
As i remember Image Renditions are implemented using query string params so you can always ignore provided by user image rendition and override it in your display template.
I imported the picture in the Item_Custom.html Template (masterpages\Display Templates\Cotrol Web Parts\Item_Custom.html) like I did in the other Templates:
<mso:ManagedPropertyMapping msdt:dt="string">'Category Image'{Category Image}:'MyCategoryImageOWSIMGE',' .... </mso:ManagedPropertyMapping>
Then Set the JS Variable:
<!--#_
var CategoryImage = $getItemValue(ctx, "Category Image");
_#-->
And manually set the Rendition ID, no matter what was choosen by the user:
<img style="visibility: visible;" src="_#= CategoryImage =#_?RenditionID=7" id="CategoryImage" onload ... >
In the past I've used the Image Field Module to require a user to provide an image of specific dimensions and it's worked great. I like the new Media Library Picker Field and it's integration with the Image Editor module to allow for cropping and re-sizing.
What I'd like to do is use the Media Library Picker Field but require the user to crop and/or re-size the image to specific dimensions. Is there any way to configure it that way? So far, the best I've come up with is to provide some help text to the user suggesting that they re-size the image to desired dimensions.
Should I just stick with the Image Field if I must have the image meet specific dimensions or is there a better way with the Media Library Picker Field?
You can't enforce that the image is supplied with specific dimensions using the Orchard 1.7+ media processing features, however you can ensure that it is displayed with correct dimensions.
Orchard 1.7 introduces the concept of media profiles, which effectively allow you to create a bunch of image transformations, name them, and then use them arbitrarily throughout your site.
On a recent project I was given a load of customer profile pictures for a testimonial page on an Orchard site. They were supplied in a variety of different sizes, and I knew I needed at least 2 different sizes (one for the main testimonial page, and a smaller one for testimonial widgets shown on other pages).
In the Admin Dashboard, I went to Media -> Profiles and created a new Media Profile called Customer_Profile_Regular, then added a Resize filter to scale it down to 100x100px (the resize filter is quite flexible, and you can create your own filters easily by implementing the IImageFilterProvider interface).
I did the same for a second profile, Customer_Profile_Small, scaling down to 50x50.
Then, using Shape Tracing, I overrode the existing Media Library Picker field display shape, and replaced it with this:
#{
var imagesField = Model.ContentItem.Testimonial.CustomerProfile;
}
#if(imagesField.MediaParts.Any()) {
<div class="customer-profile-image">
#Display.MediaUrl(Profile: "Customer_Profile_Regular", Path: imagesField.MediaParts.First().MediaUrl)
</div>
}
For the testimonial widget, it was simply a case of creating a similar shape override, supplying the other profile name.
Now I can upload any image to my media library, and use it as a customer profile image on a testimonial. Orchard will automatically resize (or perform other operations on) the image based on the profile I tell it to use, the result of which is stored in the site's Media folder so that it is only regenerated when necessary.
I'm fairly new to Orchard and I'm wondering about the "best" way of building a basic list of documents with a download link?
Say the scenario is this, I want to make a list of newsletters, the news letter are in PDF format and the users should be able to download then straight from the list view.
An admin, should easily be able to add a new newsletter and it should turn up in the list.
My current train of thought is to, all through the dashboard,
create a content type "Newsletter" with a title field and a Media picker field, using the media picker field to upload the PDF file.
Then create a query, with the filter on Content type "Newsletter"
Create a projection pointing to the query
However, this only gives me a list of content items, showing their title as links back to the actual content item.
I've tried adding a layout to the query and set it to display properties instead of content. By doing that I can get a list where I can control the "output" a bit more. And I've gotten it to list the title and by doing a Rewrite and putting in the MediaPicker.Url, it also displays the URL in the list. This is all good but here I get stuck..
As the MediaPicker.URL outputs the url in the format like ~/media/default/xyz/filename.pdf, I cant just put it into a a href, it doesn't give a correct download link to the file.
Soo, question is, am I thinking and doing this totally the wrong way or am I missing something obvious? All ideas and suggestions and more then welcome.
Use or adapt the following template override in your theme:
#{
var url = Model.ContentField.Url;
}
#if(Model.ContentField.Url != null) {
if (url.StartsWith("~/")) {
url = Href(url);
}
<div class="media-picker-field attachment-pdf">
<span>download</span>
</div>
}
Modify the text as needed. This template was a Fields.MediaPicker-PDF.cshtml that was used for a media picker field named PDF.
I'm trying to display ListItems in a GridView.
I am able to access the list items but my image is getting displayed as url .
I am using:
dr["Category"] = SPEncode.HtmlEncode(Convert.ToString(oListItem["Category"]));
The above line of code displays the list items, but when I try to display the images, it renders as http://server/images/xyz.jpg in the gridview.
Please help me in accessing the list images.
Update:
With regard to Alan's answer:
I have tried this:
foreach (SPListItem oListItem in collListItems) {
dr["Category"] =
SPEncode.HtmlEncode(Convert.ToString(oListItem["Category"]));
}
But when i try to display the images:
dr["ProductImage"] =
SPEncode.HtmlEncode(Convert.ToString(oListItem["ProductImage"]));
It still renders as: http://server/images/xyz.jpg in the gridview.
This question could use a few more details. It would help to know what oListItem[key] and dr[key] were arrays of. Whatever it is, it looks like oListItem[].ToString() method just returns a URL.
Couldn't you just new up an Image control, set the ImageSrc propery, and then add it into the GridView? You need to instantiate a new Image with each row (don't reuse an Image).
Are you using the ASP.NET GridView?
In that case you can set the filed property to your image column to Image Field.
Then you can assign the value of your converted oListItem["ProductImage"] field to the PictureUrl field.
Here's an example to get you started:
http://msdn.microsoft.com/en-us/library/aa479350.aspx
You can try the solution provided here:
http://cipriangrosu.blogspot.com/2009/05/display-item-type-icon-in-spgridview.html