Sunday, 23 February 2014

Thursday, 20 February 2014

How to Change an Image's Size and Shape in SharePoint

source: http://sharepoint.rackspace.com/how-to-change-image-size-and-shape-in-sharepoint

Scenario: I see it all the time: SharePoint content owners create sites using images that are much too large for Web consumption. It’s easy to understand why this happens. Sally Site-Owner gets a photo or image from the marketing department that was created for print or some other high-resolution format. Sally uploads the image to SharePoint and simply resizes its height and width using the ribbon controls to make the page look nice. Of course, resizing an image in this way doesn’t actually make the file size any smaller, and now end users (potentially even users on slow or metered mobile connections) will have to patiently download the large image to see the page.

SharePoint 2013 answers this problem with a SharePoint Server publishing feature known as image renditions. With image renditions, you can add images to a library and easily add them to pages using various predetermined widths and heights without downloading the full-sized image.
Steps:
I’ll assume the first two are pretty easy to figure out without me going through the steps. To turn on Blob Caching, simply navigate to the web.config file for your SharePoint site on the physical server. It is usually located in a directory similar to C:\inetpub\wwwroot\wss\VirtualDirectories\80. You can use IIS to help find the directory if you want. Open web.config in an editor like Notepad (when you hit Save, IIS will reset the SharePoint site, so make sure not to do this on production during peak hours) and use Control-F to find the first instance of “<BlobCache”. In this line, you will see enabled="false". Simply change this to “true” and hit save.

Now you can create your own image-rendition sizes fromSettings > Site settings > Look and Feel > Image Renditions. There should be a few predefined sizes you can use. To create your own, simply click Add new item, enter a name, width and height, then click Save. Now, when you add images to a picture library, you will have a rendition that matches that size that you can work with.
To work with the image renditions, navigate to your picture library and upload a picture. Once the picture thumbnail shows in the library, hover over it, click the ellipsis in the bottom-right, and then click Edit Renditions.

From here, you will see a list of all the renditions that are available, with images already created for each size. You can edit the sizing and cropping of a rendition from Click to change. This will show you a dashed box that is constrained to the size of the image rendition, and you can move and resize photo accordingly to show the image in the best possible way. This can be useful for showing faces or text in smaller sizes.
 With your image renditions set up and configured, now you can select from the different size options when you insert an image into a publishing page. After editing a page and inserting the image, from the ribbon you would just click the image tab and then choose from the Pick Rendition dropdown.
Because an image rendition is being used, the image in my example is actually a 150px by 150px file and should download quicker than a full-sized image. Pretty cool, right? What if you want to reference the image rendition directly using code or without the ribbon? Well that’s pretty easy: You can pass URL parameters to the image for either the RenditionID (the number in the image rendition list order: 1, 2, 3, etc.), or for width and/or height.

For example, in my sample to the right, the raw image URL inSharePoint was:
"http://sp15/PublishingImages/1012858_10152057897829676_916248115_n.jpg"
If I want to load the image rendition for 304x100, I can reference the image like this:
http://sp15/PublishingImages/1012858_10152057897829676_916248115_n.jpg?Width=304&Height=100

You can reference an image with just the height or width also, but if there are multiple matching renditions, the first will be returned.

Image rendition is a pretty handy feature for helping content authors create images that are sized appropriately for the Web. Oh hey, did I forget to mention that image renditions work with videos also? So be sure to try that out as well!​

Can’t crawl web apps you KNOW you should be able to crawl

http://www.toddklindt.com/blog/Lists/Posts/Post.aspx?ID=107

http://support.microsoft.com/kb/896861/en-gb

To specify the host names that are mapped to the loopback address and can connect to Web sites on your computer, follow these steps:
  1. Set the
    DisableStrictNameChecking
    registry entry to 1. For more information about how to do this, click the following article number to view the article in the Microsoft Knowledge Base:
    281308 Connecting to SMB share on a Windows 2000-based computer or a Windows Server 2003-based computer may not work with an alias name
  2. Click Start, click Run, type regedit, and then click OK.
  3. In Registry Editor, locate and then click the following registry key:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0
  4. Right-click MSV1_0, point to New, and then click Multi-String Value.
  5. Type BackConnectionHostNames, and then press ENTER.
  6. Right-click BackConnectionHostNames, and then click Modify.
  7. In the Value data box, type the host name or the host names for the sites that are on the local computer, and then clickOK.
  8. Quit Registry Editor, and then restart the IISAdmin service.

SharePoint Trick: Link to an Image Thumbnail

  • Navigate to the image in the image library where it is stored.
  • Click on the image so that you see the "item view" of the image. The default attributes such as Name, Title, and Preview will show up, along with an attribute called Thumbnail Preview.
  • The link to the Thumbnail Preview is not easily exposed, but you can "cheat" and find it by right clicking on the image and then selecting Properties.
  • Select the entire contents of the Address (URL) field shown in the thumbnail image properties. Be sure to keep scrolling in the Address (URL) field until you have captured the complete URL for the thumbnail. You will know if you have it right if you see _jpg.jpg at the end.
  • You can then paste this "secret" URL in a hyperlink column in your list and the link will show the thumbnail, not the image preview.
You can also create the link to the Thumbnail on your own by inserting the characters _t/ in front of the file name and the characters _jpg immediately after the file name in the default image URL as shown below:
Link to default image preview:
  • intranet/sitename/libraryname/foldername/imagename.jpg
Link to Thumbnail for the same image:

  • intranet/sitename/libraryname/foldername/_t/imagename_jpg.jpg

SharePoint Governance: To get started, it’s important to have the right conversations!


source: http://www.networkworld.com/community/blog/sharepoint-trick-link-image-thumbnail

patterns & practices SharePoint Guidance

patterns & practices SharePoint Guidance​
 
 
Error Logging in SharePoint
http://spmatt.wordpress.com/tag/sharepoint-guidance-library/

SharePoint 2013 development overview



http://msdn.microsoft.com/en-us/library/ff798413.aspx


Put the JavaScript or XAP files in a SharePoint library, and enable binary large object (BLOB) caching. BLOB caching instructs SharePoint to cache BLOB content, such as JavaScript and XAP files, on the SharePoint Web front-end servers. It also enables client browsers to cache the content. If BLOB caching is not enabled, the HTTP header that returns the JavaScript or XAP resources to the client will instruct the browser not to cache the files. It does this by including a cache-control: private directive and by setting an expiration time in the past. As a result, neither the client browser nor the web front-end server will cache the content, which instead will be retrieved from the content database on every request. BLOB caching is a SharePoint Server 2010 feature and must be enabled in the configuration files for the SharePoint web applications, so to some degree you are at the mercy of the farm administrator. For more information on BLOB caching, see Disk-Based Caching for Binary Large Objects.
http://msdn.microsoft.com/en-us/library/aa604896.aspx 

REST in SP2010



SHAREPOINT GUIDANCE FOR SHAREPOINT 2013
http://graegert.de/blog/sharepoint-guidance-for-sharepoint-2013/ 

SharePoint Development Debugging

I've been reading a lot of posts on how to get debugging going when attaching to the w3wp.exe process.

Disable 'Enable Just My Code' in Visual Studio

This blog post started me off in the correct direction by setting the Tools | Options | Debugging setting correctly.

Modify the web.config

Furthermore, it prompted me to change the web.config value from debug="false" to debug="true". The web.config file can be found in the Inetpub\wwwroot\wss\VirtualDirectories\ folder, each folder in there maps to an IIS Web Application which you can find by going to IIS Manager and looking at the Home Directory.
To get full blown ASP.NET errors rather than SharePoint branded "useless" ones follow these steps:

Setting CallStack=true

By default, WSS will redirect a user to the error page whenever an unhandled exception is encountered during the render cycle.  To disable this behavior, open your web.config and set CallStack="true" in the <SafeMode> node.  This allows you to see a typical Asp.net error page.

Setting customErrors mode...

The next step would be set mode="Off" in the <customErrors> node.  This instructs Asp.net to show you a complete error report rather than a generic "Server Error" page.

Creating pdbs

For each project you wish to debug, you need to ensure that you are creating pdbs. I am using the really cool stsdev app to create my projects and had to modify it to create pdbs by going to Project Properties and on the Build tab in the Output Section click the Advanced button. 
Then ensure that Debug Info is set to pdb-only. 


Attach to Process

The author of the previous referenced post also pointed me to running iisapp on the command line to output a list of all the running instance to know which process to attach to:
Then when you select Debug | Attach to Process the ID matches to the PID in the output of iisapp. Note you need to check 'Show processes from all users' as w3wp.exe will be typically running as another account.

You can check that you have the correct id by pressing CTRL-ALT-U and this will list all the Modules that are loaded with statuses on the symbols that are available (e.g. that when you create a breakpoint it'll work rather than giving you a 'No symbols loaded' errror).

Sometimes there are just too many instances of w3wp.exe to pick from. An easy way to just let the system sort things out for you, rather than inserting a breakpoint, is to insert the following line in your code:
System.Diagnostics.Debugger.Break();

Notes for Visual Studio Debugging Newbies


Once you are actually debugging and can step through code after it breaks on a breakpoint...you can also use the Immediate window to inspect objects by pressing CTRL-ALT-I. From here you can get up intellisense on any object in context which is a great way to inspect things like whether a SharePoint list has an Event Receiver on it or not. 
 

The web server process that was being debugged has been terminated by Internet Information Services (IIS)

If you are debugging in IIS7.0 you will find that you will receive this error if you leave it on a break point for too long.



 
Unknown macro: {NewCode}
---------------------------
Microsoft Visual Studio
---------------------------
The web server process that was being debugged has been terminated by Internet Information Services (IIS). This can be avoided by configuring Application Pool ping settings in IIS. See help for further details.
---------------------------
OK Help
---------------------------

The Resolution is to follow these steps on MSDN - Error: Web site worker process has been terminated by IIS
 


Optimizing SharePoint sites



source: https://www.nothingbutsharepoint.com/sites/devwiki/SP2007Dev/Pages/SharePoint%20Development%20Debugging.aspx

Get SharePoint fields internal name

Use this powershell command:
$list = (Get-SPWeb "http://portal.contoso.com").Lists["Demo List"]
$list.Fields | ?{$_.title -eq "Title"} | FT Title, InternalName
Example:
PS C:\Users\spt.prod.installer> $list = (Get-SPWeb "http://emflow").Lists["work items"]
PS C:\Users\spt.prod.installer> $list.Fields | ?{$_.title -eq "Title"} | FT Title, InternalName
Title                                   InternalName
-----                                   ------------
Title                                   Title
Title                                   LinkTitleNoMenu
Title                                   LinkTitle
Title                                   LinkTitle2


PS C:\Users\spt.prod.installer> $list.Views | FT viewfields

ViewFields
----------
{Activity_x0020_ID, Status, Entry_x0020_Date, SLA_x0020_Date...}
{Modified, Activity_x0020_ID, Status, Entry_x0020_Date...}
{Modified, Activity_x0020_ID, Assign_x0020_Bucket_x003a_Group_, Entry_x0020_...
{Activity_x0020_ID, Status, Entry_x0020_Date, SLA_x0020_Date...}
{Modified, Activity_x0020_ID, Assign_x0020_Bucket_x003a_Group_, Entry_x0020_...
{Modified, Activity_x0020_ID, Status, Entry_x0020_Date...}
{Activity_x0020_ID, Status, Entry_x0020_Date, SLA_x0020_Date...}
{Activity_x0020_ID, Assign_x0020_Bucket_x003a_Group_, Entry_x0020_Date, SLA_...
{Activity_x0020_ID, Assign_x0020_Bucket_x003a_Group_, Entry_x0020_Date, SLA_...
{Activity_x0020_ID, Status, Entry_x0020_Date, SLA_x0020_Date...}
{Activity_x0020_ID, Status, Entry_x0020_Date, SLA_x0020_Date...}
{Activity_x0020_ID, Status, Entry_x0020_Date, SLA_x0020_Date...}
{Activity_x0020_ID, Status, Entry_x0020_Date, SLA_x0020_Date...}

PS C:\Users\spt.prod.installer>