Hack Forums
[PHP] How to make live image positioning possible? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Web Development (https://hackforums.net/forumdisplay.php?fid=183)
+---- Thread: [PHP] How to make live image positioning possible? (/showthread.php?tid=3715017)



How to make live image positioning possible? - iWatch - Aug 25, 2013

I am working a Social Network of mine. When I upload a picture, it automatically centers the pictue and uses it as profile cover. The thing is I want the user to choose how to position it while it is uploaded. I guess I have to use PHP to do it. Any clues on how to do so? In the meanwhile, I will be making searches on Google to find any answer.

Of course, I want the final position to be saved.


* - thegentlad22 - Aug 25, 2013

You would have to use javascript. You will use ajax to save the changes made.

PHP is server sided. Javascript is client sided. For the user to be able to interact with the website like drag a picture around it's done on the client side. So, javascript will give you that effect where you can drag the image and then click a button to save it. Once the image is save it will look for that images id or name. You then grab it's css value for left and right etc it's position. Then take those position values and then using ajax you post them back to your php script which will first make sure the values are numbers and then you can save it. Then when you have to display the image you would have to grab these values from your database and insert them in the css code for the position values.

Hope this helps any. I just gave you the concept. Good Luck 🤝

Also look into jquery UI they have dragging and resize features already made. I myself already have a working code already made. So, I already done this process that you're going thru but more complex then what you're trying to do.


* - Quad - Aug 25, 2013

jQuery and jQuery UI will probably come in handy.