{"title":"Loading Facebook Images","id":52027,"link":"https:\/\/env.averta.net\/en\/step\/loading-facebook-images\/","parent":[51854],"content":"<p>With Master Slider dynamic sources, you can load your public images from a Facebook gallery or your timeline, and show them as a slider. To create a Facebook slider, first, you need to create a template for the slider. Its markup is very similar to a custom slider markup. The snippet below defines a slider template:<\/p>\n<pre class=\"lang:xhtml decode:true \">  &lt;div class=\"master-slider ms-skin-default\" id=\"masterslider\"&gt;\r\n      &lt;div class=\"ms-slide\"&gt;\r\n          &lt;img src=\"...\/path\/to\/blank.gif\" data-src=\"{{image}}\" alt=\"{{name}}\"\/&gt;           \r\n          &lt;img class=\"ms-thumb\" src=\"{{thumb}}\" alt=\"{{name}}\"\/&gt;\r\n          &lt;p class=\"ms-layer\"\r\n            style=\"background:rgba(255,255,255,0.5); padding: 20px;\"\r\n            data-type=\"text\"\r\n            data-offset = \"{origin:bl; x:50px; y:50px;}\"\r\n          &gt;\r\n              {{name}}&lt;br&gt;\r\n              by:{{owner-name}}\r\n          &lt;\/p&gt;\r\n      &lt;\/div&gt;\r\n  &lt;\/div&gt;<\/pre>\n<p>As you can see in the example above, you just need to define one slide in the slider and specify dynamic parts by <code>dynamic tags<\/code>. Dynamic tags will be replaced by the related content after loading data from Facebook.<br \/>\nAs demonstrated in above example, dynamic tags specifies by locating between<br \/>\n<code>{{<\/code> and<br \/>\n<code>}}<\/code><\/p>\n<h2>Supported dynamic tags<\/h2>\n<table>\n<thead>\n<tr>\n<td>Dynamic tag<\/td>\n<td>Description<\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>{{name}}<\/code><\/td>\n<td>Photo name<\/td>\n<\/tr>\n<tr>\n<td><code>{{thumb}}<\/code><\/td>\n<td>Photo thumbnail path<\/td>\n<\/tr>\n<tr>\n<td><code>{{image}}<\/code><\/td>\n<td>Original photo path<\/td>\n<\/tr>\n<tr>\n<td><code>{{owner-name}}<\/code><\/td>\n<td>Photo owner name<\/td>\n<\/tr>\n<tr>\n<td><code>{{link}}<\/code><\/td>\n<td>Photo link in Facebook<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Setup Facebook gallery<\/h2>\n<p>After specifying the slider markup, you need to set the Facebook images source and API data. You can set them after slider JS setup. Below you can find an example.<\/p>\n<pre class=\"lang:xhtml decode:true \">    var slider = new MasterSlider();\r\n \r\n    slider.control('arrows');  \r\n    slider.control('bullets');\r\n    slider.control('thumbnails' , {\r\n          width:127,\r\n          height:137,\r\n          arrows:false\r\n          fillMode:'fill'\r\n    });\r\n  \r\n    slider.setup('masterslider' , {\r\n        width:900,\r\n        height:600,\r\n        space:5,\r\n        fillMode:'fit'\r\n    });\r\n\r\n    MSFacebookGallery.setup( slider , { \r\n        username :'natgeo',\r\n        count:64,\r\n        thumbSize:'320',\r\n        imgSize:'480',\r\n        type:'photostream',\r\n        token:'[The Facebook access token]'\r\n    });\r\n<\/pre>\n<p>As demonstrated in the example, to setup Facebook gallery you need to use<code>MSFacebookGallery.setup<\/code>. This method has two parameters. First parameter is the instance of the slider and second one is Facebook api options.<\/p>\n<h2>Facebook API parameters<\/h2>\n<table>\n<thead>\n<tr>\n<th>\n<div>Option<\/div>\n<\/th>\n<th>\n<div>Default<\/div>\n<\/th>\n<th>\n<div>Description<\/div>\n<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>token<\/td>\n<td>null<\/td>\n<td>The Facebook access token, you need to generate a new token in Facebook to<br \/>\ngain access to the data. For more information,<br \/>\ncheck out <a href=\"http:\/\/env.averta.net\/en\/get-the-facebook-access-token\/\" target=\"_blank\" rel=\"noopener\">this page<\/a>.<\/td>\n<\/tr>\n<tr>\n<td>username<\/td>\n<td>null<\/td>\n<td>Specifies Facebook username, this is required when you want to show a photostream<br \/>\nof a user.<\/td>\n<\/tr>\n<tr>\n<td>albumeId<\/td>\n<td>null<\/td>\n<td>Specifies the album ID.<\/td>\n<\/tr>\n<tr>\n<td>type<\/td>\n<td>&#8220;photostream&#8221;<\/td>\n<td>Specifies the source type of photos from Facebook. &#8220;album&#8221; loads photos from<br \/>\na public album and &#8220;photostream&#8221; loads user timeline latest public photos.<\/td>\n<\/tr>\n<tr>\n<td>thumbSize<\/td>\n<td>&#8220;320&#8221;<\/td>\n<td>Specifies the size of thumbnails, it accepts<br \/>\n<code>orginal\/960\/720\/600\/480\/320\/130<\/code> values.<\/td>\n<\/tr>\n<tr>\n<td>imgSize<\/td>\n<td>&#8220;original&#8221;<\/td>\n<td>Specifies the size of photo, it accepts<br \/>\n<code>orginal\/960\/720\/600\/480\/320\/130<\/code><br \/>\nvalues.<\/td>\n<\/tr>\n<tr>\n<td>count<\/td>\n<td>10<\/td>\n<td>Specifies the total number of photos should be loaded by slider.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","type":"solution"}