Tuesday 7 August 2012

Display Slide Show Images within fixed size


The Picture Library Slide Show Web Part show the images stored in a picture library with slide show effect.
This slide show web part displays the images with it's original size. Due to this the web part changes its size according to the image size. If we want the slide show to run within the specific size on the page then we need to control the size of the images to the fixed length during runtime.

To achieve this we need to add the CEWP above the picture Library Slide Show web part & insert the following script in that web part.

<style type="text/css">
.ms-WPBody TD {
    PADDING-BOTTOM: 0px; BORDER-RIGHT-WIDTH: 0px; MARGIN: 0px; PADDING-LEFT: 0px; WIDTH: auto !important; PADDING-RIGHT: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; HEIGHT: auto !important; VERTICAL-ALIGN: middle; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px
}
.ms-WPBody TD DIV {
    PADDING-BOTTOM: 0px; BORDER-RIGHT-WIDTH: 0px; MARGIN: 0px; PADDING-LEFT: 0px; WIDTH: 100% !important; PADDING-RIGHT: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; HEIGHT: auto !important; VERTICAL-ALIGN: middle; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px
}
.ms-WPBody TD IMG {
    PADDING-BOTTOM: 0px; BORDER-RIGHT-WIDTH: 0px; MARGIN: 0px; PADDING-LEFT: 0px; WIDTH: 260px !important; PADDING-RIGHT: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; HEIGHT: 190px !important; VERTICAL-ALIGN: middle; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px; align: center
}
.s4-wpcell-plain {
    PADDING-BOTTOM: 0px; BORDER-RIGHT-WIDTH: 0px; MARGIN: 0px; PADDING-LEFT: 0px; WIDTH: 100% !important; PADDING-RIGHT: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; HEIGHT: auto !important; VERTICAL-ALIGN: middle; BORDER-LEFT-WIDTH: 0px; PADDING-TOP: 0px
}
.ms-PartSpacingVertical {
    MARGIN-TOP: 0px
}
.style1 {
    COLOR: #808080
}</style>


We can fix the height & width of the image in the .ms-WPBody TD IMG css.

10 comments:

  1. It works! Very helpful piece of code. Thanks

    ReplyDelete
  2. I tried this code.. it works , but the issue is , it is affection hight and widht of other webpart on that page. How to overcome that ?

    ReplyDelete
    Replies
    1. Try the jquery from the following link which will restrict the height & width of only the Slide Show Web part
      http://spcodes.blogspot.in/2012/12/jquery-to-restrict-image-size-to-fit.html

      Delete
  3. This doesn't seem to work for me. After pasting the code into the page, it appears to function correctly ... until I click save. Then it's jacked again. Any ideas?

    ReplyDelete
  4. Tried the code and the image size worked but now I have the tool bar below which gives the options to pause forward are back are now very big. How do I resize them?

    ReplyDelete
    Replies
    1. I have same problem, did you achieve your goal?

      Delete
    2. i have the same problem. were you able to fix this error?

      Delete
  5. Beautiful. Thank you.

    ReplyDelete
  6. sorry but i am abit confused
    i have a subsite and on it i have added the picture library slideshow
    u said we need to add a CEWP above the picture library slideshow. how is that done?
    and how do i add the code?
    are u saying i should add the CEWP first and inside of it add the picture library slideshow? or i should add them seperatly? how do i add the code above on CEWP

    thanks

    ReplyDelete
  7. It doesn't work for me. Is there a video of this somewhere?

    ReplyDelete