I am working with php. I have images kept in order. When i do query the images comes in order but when they load they does not load in order. The small images load first and then big images. For example I have 5 images. These images should be loaded in order(1,2,3,4,5). But here its not happening. Image 4 loads first, then 2, 1 and so on. So what can i do for this problem? Hope to get solution.
Thanks in advance.
If you are speaking about the order images are displayed by a web browser, you do not have much control over that, as long as you have several <img> tag on your page :
the browser will request the images from the server in the order it wants (most probably, the first <img> tag encountered will be the first image requested)
each image takes some time to download ; and each image is displayed when it's downloaded ; considering small images should be downloaded faster, small images should be displayed first... depending on the order they were requested -- see previous point.
In the end, if you want absolute control on the order the images are displayed, your initial HTML should probably not contain all the <img> tags: a solution would be to add those, in the right order, when the previous image is downloaded.
This can probably be done with some JavaScript code, to detect when an image is loaded (event "load") ; and when an image is loaded, just add a new <img> tag to the page, for the next one; and so on.
But I wouldn't go with such an idea: it won't work if JS is disabled, your images will not be seen by search engines.
You can control everything on your web server, but nothing on network or browser sides.
A possible solution is to build a single image containing your five images and display each relevant portion to its dedicated position.
Have you tried preloading them with a JavaScript library?
Not sure how you would implement this in PHP, but in the past I have usually had the a 'order' field for each image, then the images were added dynamically according to the 'order' field.
As you should have guessed, image is loaded according to their sizes. Ofcourse, the smaller ones will load before the bigger ones. And yeah, as eyze said, wat about you preload them with a javascript preloader and display them in the right order?
Related
My MODX site needs to grab the first image from all pages for Open Graph Meta tags, which will be plugged into the Head chunk for all templates.
The problem with this is that not all images are located in the content part of a page. Some are located inside Chunks and others inside TVs. (Finding an image tag from the content is not an issue.)
It might be possible to get all Chunks and TVs and loop through their values to check for images.
But is there a way to get the <body> contents of the resource?
Probably several ways, you can try writing a plugin to parse through the entire content of a page, looks like the OnWebPageComplete event may be the one to use (take a look at the different events to see if one is more appropriate}
You can try and grab the resource from the cache, keeping in mind that any chnks/snippets/TVs called in the page un-cached will not show up in the resource cache file.
You can get a list of TVs once you have loaded a resource & then use getTVValue to get the value.
If you have an image in a chunk, getChunk might work [might, I've never tried to use it that way] to get it's contents but I would image that the image in a chunk would come from a TV ~ so you should be able to retrieve it with getTVValue.
You could also just setup a TV for the OpenGraph image and explicitly set it on a page by page basis.
Probably writing a plugin & some regex is going to be the least painful way of going about it.
i have a question to ask you. So I have on my webpage a showcase that has some images that keep playing. I used JCarousel to build it. The thing is that when i first enter on the page i can't see the image or I see only a part of it. I suspect that this is because the site a few seconds while it loads all the images it has. My question is: how can I make certain images be the first ones to be loaded? Or how can I prioritise the way the images load on the page? By the way I'm doing this in html,php using javascript and ajax and the images are taken from a database.
Thank you very much!
If you Base64 encode them, you can put them in the CSS, or HTML. It will really increase the side of a page, so perhaps encode a low resolution picture, and then replace it with highres when it loads. That is, a preview image.
Try this tool/guide.
Image this scenario:
There is a picture locally in my server, where a sketch is displayed, and there is a "blank hole" area on it.
Then, a user can upload another picture to my server.
What i'm trying to achieve is this:
After image upload is finished, the first image (the one with the "hole") is displayed, and behind it is displayed the user's photo, so that you can see it through the "blank hole" area of the first photo.
Then the user can move his picture (drag & drop style) so he can choose which area of it is visible through the "blank hole".
Then i would like to save the result - by merging the 2 photos or keeping the position of the user's picture in a db so i can display it again later.
(Something like this more or less)
What kind of technollogy should i look for? I'd guess javascript(for the drag & drop) or html5 or php(for merging the photo)?
Are there any libraries that i can use?
I hope my explanation isn't too messy, i didn't even know how to google for it.
I don't know if there are better solutions (and I suspect there are), but I suspect all of this can be done with not too much trouble. Here's a rundown of one way to approach the problem:
Use a JavaScript-powered "upload widget" such as uploadify to enable your user to upload "his" image to the server. The server will do some processing on the image (e.g. resize and crop to suitable dimensions) and save it using e.g. PHP's gd library. It will return a URL to the "prepared" image back to the browser -- all of this through AJAX.
The browser then has a URL to the user's image, so using more Javascript you can dynamically add an element that displays it inside the page and allow the user to move it around with e.g. jQuery draggable. Compositing the draggable image behind your static content (the image with the "hole") is a detail you will have to take care of using a combination of HTML, CSS and again Javascript.
When the user is done, use an AJAX call (e.g. again jQuery) to inform the server of the image's positioning (this will be available through the facilities of the Javascipt framework you have selected). The server can then "compose" the two images together (gd or something equivalent once more) and return to the browser a URL through which the final product can be accessed.
Of course there are lots of details to take care of here, but knowing exactly what the plan is should help you get started.
Have a look at the PHP GD extension. If it's installed, it's pretty easy to have an image (with a transparent center) to be merged on top of a second image that a user would upload.
Have a look at http://php.net/manual/en/function.imagecopymerge.php
Ok to get you started, yes use a JavaScript drag and drop module for the placing of the image. You can record the x /y cordinates relative to the container. Do the image merging with a PHP image library / Class. Something like this : http://www.phpclasses.org/package/3930-PHP-Generate-an-image-from-the-combination-of-2-images.html
I'm displaying pieces of an image in a large grid created from divs. I'm using the background-image and background-position to display portions of the image. The problem I'm running in to is that a user can simply open up firebug and see the entire image (which defeats the purpose of the game).
I've attempted to mask the path using a php script as the URL but if the user navigates to the php file, they can still see the image. It would appear that anything I do with the CSS is entirely client side so denying everything outside the localhost in my .htaccess won't work.
Any suggestions?
The over arching goal is to have an automated way to split and display pieces of the image into a grid.
If you deliver the whole image to the browser, the browser holds the image and has every right to show it to a user. I don't think you can prevent the browser from showing it. I'm afraid you will have to deliver the image in pieces, or perhaps write your whole game using <canvas> and play around with images as pixel data. :)
This question is a bit open at the moment as I'm not sure the idea is even possible.
So far I've loaded an image from a url, and then used jQuery UI draggable feature to allow the user to drag html text (which has been replaced using cufon font replacement) over the top of the image.
The major step (which is what my question relates to) is being able to take the image and text layered over the top of the image, and save the result, either to the server, or potentially offer the option to save the altered image to the user's HD, or what would also be useful is to upload to facebook using the facebook API, but this is something I know is possible.
It all hangs on whether it's even possible to achieve the first step, which is to save the image and layered text as a combined image?
I wonder if there is a PHP/jQuery solution that would allow me to do this?
My suggestion would be to have an internal URL that outputs the final image using jQuery and PHP, then take a screenshot using webkit2png of that page. You should know the dimensions etc., so you'll be able to crop down the resulting screenshot to just the region you're looking for.