Device orientation & pagination - php

I'm currently working on a mobile site that has tiles which represent each article. The pages have 15 tiles on them which is clean and works for both orientations on a mobile device. I recently added a featured article which takes up two space tiles worth of page space, so now I have one tile that is widowed on the bottom of the page.
Using some media queries I'm able to show/hide the last two tiles which works great until users click to the next page of tiles. If a user is in portrait orientation then they will miss two article tiles because they were hidden on the last page.
So I want to create some type of AJAX function that allows me to check the orientations and dynamically change the tile count request server side. Is this possible?

Jquery Mobile offers methods to look and know the orientation of the device.

Related

Issue in loading time and size of images for PDF first page preview

I am working on website which is having huge amount of PDFs shown to its page. Those PDFs are listed on the page. The count may be 150 on every page.
We need to show the preview of first page of those PDFs to show the user whats inside every PDF.
What I am doing now?
While uploading those PDFs on clouds, I am creating previews of first page of those PDFs (1 small preview and 1 large preview) using a tool called PQScan.
Small preview will be shown on page by default, Large preview will be shown on mouse hover.
What is the problem?
For around 150 PDFs per page, The loading time of small and large preview(.gif/.jpeg/.png images) from cloud is taking a lot of time.
Image for refrerece on how I am showing -
Is there any better way to tackle this problem to resolve the issue faced? Also the size occupied by these images on cloud?
Some suggestions from my knowledge are:
Use Lazy loading technique to improve your page load time. Refer Google Documentation to know more about this.
Save random pages of the document as single images (such as cover page, some 2-3 random pages in between). Then instead of automatic slideshow or GIF, only show the cover page preview image. And on mouse hover, you can load and display other pages as slideshow or any animation effect you can implement.
Use Next Generation image formats as they are much smaller compared to older formats. Refer here for more detailed information.

PHP and Jquery Multiple Images Crop (After Area Selection on Any One Image)

I am currently working on a project in PHP which involves uploading PDFs, converting them into images and then selecting a perimeter (area) on any one of the 4 uploaded PDFs (later images) as a reference, and finally crop those images all at once.
I have converted PDFs to images successfully (at a very high resolution), now what I need to do is to create a page say "Specify Perimeter", where I want to place any one of the four images as a reference for area/perimeter selection (since image would be of large size, a zoom functionality would also be required).
Once i have selected the area/perimeter, then I would click a button "Crop or Save Perimeter". And the server should take that perimeter and crop current as well as other 3 images with same perimeter.
Note: All images would be almost identical with same dimensions.
Here's a front-end tool you might find useful:
https://fengyuanchen.github.io/cropperjs/
And a back-end tool you might find useful:
https://github.com/masterexploder/PHPThumb

Query a image database with mouse coords

Thanks for taking the time to read my post.
I am looking for some options/suggestions/general comments on how I might be able to query a database of images based on mouse location.
Essentially, I have a database (on a seperate companies server) that contains a few images, what I would like to do is return an image to my website depending on where my mouse is based in the browser.
so if I click top left, i'll get a zoomed in picture of the top left of the landscape (a seperate image), if I click bottom right, I will get a zoomed in picture of the bottom right (again, seperate image).
I am a newbie to HTML/PHP/CSS but not to C++/C/Delphi, I'm sure I can do this, but I can't see the wood from the trees as to what I actually have to do!
I am using my own server (hosted by 1&1) and a Drupal webpage.
If anyone could help that would be great!
Many thanks for your time,
Kay
HTML map and use javascript (probably jQuery) to bind to each <area> and do something (in your case, popup/zoom a separate image)

Displaying a different Adsense ad based on browser width

I have a responsive design I am working out that starts around 960 pixels wide and reduces down to 320px using css3 media queries.
I'm currently using a 728px banner above and below my content, but this obviously breaks once you get below 728px.
What I need is the easiest way to display a smaller ad once the browser width goes below 728px. I can't simply load the ad units in divs and hide them using css because this is against adsense TOS.
Any suggestions?
What about doing it with javascript. Your page can load with no ad unit html code at first but it could detect screen size with javascript and then add to the page the appropriate ad units for the initial browser size. Only a desktop type browser can resize the viewport window so maybe just forget about that issue. People resizing the browser viewport probably are playing around or whatever and will still see the first AD impression. Think about it, you open a browser and then you resize the window because of not being able to see properly and even then how many times are you going to be doing it as you navigate a site from page to page, maybe once (the first time). Google doesn't want you mucking up AD impressions so I don't think this violates TOS to load the ads based on window size. Just don't destroy the ads after resize and load others (risky). Mobile devices can't resize viewport (other then rotate) and they will always see the correct AD size.
Ryan Underdown provides a simple solution at http://ryanunderdown.com/ppc/responsive-ads-with-adsense.php
Another SO question: Making Adsense Responsive
Even Google's CSE will not show ads on your site if the initial viewport size is too small for the ads and even after you resize the window larger it won't reload ads in it until browser is refreshed.
Use a responsive AdSense unit.
If this is not what you want, use JavaScript to detect the available width then select the appropriate ad unit, then inject it to your content.
1st - I did AB test of 728 leaderboard vs 336 large rectangle. 336 performed over 75% better, over 300,000 page views.
Point is - don't use 728, and also don't recommend using responsive ad unit at all.
My other test improved earning by over 100% by switching from responsive ad unit to 2 fixed size rectangles (one for mobile, one for desktop/tablet).
You can use something like this to determine user agent:
$iPod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
$iPhone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$iPad = stripos($_SERVER['HTTP_USER_AGENT'],"iPad");
Then based on user agent you can show either "mobile" or "desktop" ad size.
Here is how to use USER_AGENT to select which ad to show: http://www.adsenseninja.com/show-mobile-optimized-adsense-ads-for-smartphone-visitors-automatically-free-mobile-ads-php-script-for-wordpress/
It is possible via hidden div and media libraries but I think It's forbidden by google :(

Blog with heavy load of pictures-Speed up page

i'm building a travel blog (Php) where I might be loading dozens of pictures (size 500x375 weight 150-200kb) so that the page weights more than 4-5Mb.
Which is the way to go apart from caching/gzip to decrease waiting time and make a better user experience?
I'm on a shared server as my budget is very low
thanks
Some options:
split up the images across multiple pages
use a 'lazy load' script that will only request images as they come into the viewport
use AJAX to request images as needed via a user action
leverage external hosting of the images (flickr, etc) to split the server requests amongst different servers.
If you're displaying dozens of images on one page, I would consider just showing small images / thumbnails that get enlarged when the visitor clicks on them.
There are some points that solve this issue
1) Show few images and below that show more link or icon
2) After clicking on that give ajax call and show other images
3) Also you use 'jQuery lazy loading plugin'(it's very easy to integrate..click here to see integration step)

Categories