The Panorama 360 Viewers Found HERE and HERE are easy to use if you just copy and paste the code available in their documentation and place the 360 images right next to the index file and open it in browser. However is there a way to Dynamically bring images from Database and render the 360 images in the view like this (link)
The code given in panorama viewer file gets images in Panorama Array like this
var panoramasArray = ["01.jpg","02.jpg","03.jpg","04.jpg","05.jpg","06.jpg"];
var panoramaNumber = Math.floor(Math.random()*panoramasArray.length);
What if we have to display only one image? Has anyone tried to bring images dynamically from database and rendered a view with 360 viewer in it?. I have seen an unanswered thread here but no one replied that question.
For many of Codeigniter Developers and those who have been developing real-estate websites, either wanting to or have tried but failed to integrate 360 image viewer in their websites. Here is the exercise which I have done and learned so far.
How it works?
What we need?
Above is my Controller function which uploads the 360 Image and saves the name in the database. Nothing Fancy, I am not using CI upload Library
This is my Database Table to store 360 Image names
Above is the Controller Function which gets all the data from Models and Calls the view to render the page. You can see in the controller function the following lines
get the list of 360 images from the model. Now in the property detail view I am again calling to the view which actually displays the 360 image in an < iframe > and sending the image name to the URL which displays the 360 image.
I have another controller load360 with a function showImage which receives Image name as parameter and calls the view which displays the 360 image
}
In my show360 view which I am calling here I am simply echoing the image variable along with the image path.
And Jobs Done. You can see how views are rendered on following links
Double 360 Images
Single 360 Image