Posts

Showing posts with the label image

SharePoint 2010 / jQuery - Swapping Images

Web part uploaded and forgot to include the image in the feature? This could be a potential issue on a managed SharePoint 2010 environment (Office 365 - Dedicated, etc.). The reference points to a path in the _layouts folder. How can I temporarily resolve this issue until I update the project? Simple. Modify the master page or add a content editor web part with the following jQuery, and store the image into a location that is easily accessible. jQuery(function() { jQuery('img[src="/_layouts/images/old-image.png"]') .attr("src", "/subsite/PublishingImages/new-image.gif"); });

C# - ListView Item Spacing (Padding)

I'm perplexed at the reasoning that the ListView control, has no direct spacing/padding property. I am utilizing the ListView in the capacity of images, using the View state, View.LargeIcon. There is a method to modify the spacing/padding between the ListViewItem(s). Initially, you'll need to add: using System.Runtime.InteropServices; Next, you'll need to import the DLL, so that you can utilize SendMessage, to modify the ListView parameters. [DllImport("user32.dll")] public static extern int SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam); Once completed, create the following two functions/methods: public int MakeLong(short lowPart, short highPart) { return (int)(((ushort)lowPart) | (uint)(highPart << 16)); } public void ListViewItem_SetSpacing(ListView listview, short leftPadding, short topPadding) { const int LVM_FIRST = 0x1000; const int LVM_SETICONSPACING = LVM_FIRST + 53; SendMessage(listview.Ha...

SQL - Inserting Images

If there is ever a need to store images into SQL Server, it can be done in a few simple steps; you will need to create the database, the table names and insert your images. CREATE TABLE ImageResource ( ID INT(5) NOT NULL AUTO_INCREMENT, NAME NVARCHAR(255) NULL, IMAGE IMAGE NULL, PRIMARY KEY ('ID') ); Once the table has been created, you simply do the insert via the following: INSERT INTO dbo.ImageResource (NAME, IMAGE) SELECT 'LOGO_NAME' AS NAME, * FROM OPENROWSET (BULK N'C:\FILENAME.PNG', SINGLE_BLOB) AS IMAGE If the image needs to be updated, use the following: UPDATE dbo.ImageResource SET IMAGE = ( SELECT * FROM OPENROWSET(BULK N'C:\FILENAME.PNG', SINGLE_BLOB) AS IMAGE ) WHERE NAME = 'LOGO_NAME'