I would like to calculate the height and width of the main content area of a blogpost server side. This is something that needs to be done for many different websites. But mostly Wordpress sites. I need the width and height off the blogpost for an algorithm as parameters.
I could ask the user for this info, but unfortunately the people who are using this website are not technical so they have no idea how to find this information (eg in a developer tool). If the numbers are incorrect the outcome of my algorithm is most likely incorrect.
First I tried if there was a way to do this with PHP, but was not able to find it. Then I thought about using Java and then use PHP to communicate with Java again. Couldn’t find anything either. Next step could be to let a user “select” a div or area and calculate it from there, but this would not be ideal, because you would need the user input every time you would like to make a calculation. One other problem with this would also be how to find the main content div / element first?
If I am able to find the main content div server side automatically I could load the blogpost in an iframe and calculate the width and height with jquery. But how would you find the main content div?
Anyone who has a way to solve this problem? I am kind of open to any solution without the user input.