Jump to content

Recommended Posts

Hi folks,

 

I'm stuck up with a function(or) code I need to implement.I need to get the images from an url(which actaully are in the local server) dynamically and display them as a thumbnail....here is the link I'm talking about to get a clear idea http://omars.gmu.edu/items ...an image should be displayed on the left of every item that is displayed...

 

Here is how an image is to be retrieved...when I click on any item it redirects to another page,which on this page will be http://omars.gmu.edu/items/show/2536,when clicked on "Paper: "The Center for Interactive Management," October 1981"...When the page is scrolled down,an Identifier tag can be seen which has an url...when clicked on that,it again redirects to the link provided...the clickable version of the page is not updated yet...sorry for the inconvenience....Finally,this page contains some images,pdf,documents which should be displayed as a thumbnail in the browse items page I'm worrying about http://omars.gmu.edu/items...

 

Any help is greatly appreciated....

Link to comment
https://forums.phpfreaks.com/topic/191883-getting-image-from-url-dynamically/
Share on other sites

im assuming by image from url, you mean you need to get a certain image from a certain page (that certain page residing at the URL in question)

 

There are numerous ways to do it, but using the Curl library,  or simply using the file_get_contents() function will get the raw html of the page. From there you could simply use regex or the html DomDocument class to get the image you want

Hi Ram,

 

http://omars.gmu.edu/items/show/2536,when clicked on "Paper: "The Center for Interactive Management," October 1981",it rediects to the page which has a label named "Identifier"....It has an url which is http://hdl.handle.net/1920/5657 in this case,and it is different for every item in every collection..And finally when clicked on that link,infact,the main page that contains pdfs,images,docs that are click-able/download able(sorry for the server is down right now, you cannot view this page)...What I'm supposed to do is get the images/docs/pdfs from that page and display them as a thumbnail in thishttp://omars.gmu.edu/items/show/2536 page....

 

In short,I need to get images/docs/pdfs from http://hdl.handle.net/1920/5657 and display that as a thumb nail in http://omars.gmu.edu/items/show/2536...and should be same for every item wehn browsed....

 

Maddali

Hi Mikesta,

 

Thanks for the reply,that's exactly what I'm talking about...Is it possible to retrieve the links of image/docs/pdfs that is on the remote server and get it displayed as thumbnail,that corresponds to each item...Also,when I roll over my mouse over the different images,pdfs,docs in different items or collections,I noticed that they have some part of url in common,which are stored in the server...However,I couldn't manage to get a function that does my task,which I think is beyond my knowledge...could you please help me providing a sample code/function that works in my case....

 

Thanks,

Maddali

well, if you have the raw html, a simple regular expression (regex) would probably do the trick. Can you give a couple example urls?

 

preg_match() regex function:

http://php.net/manual/en/function.preg-match.php

 

site with regex tutorials

http://www.regular-expressions.info/

 

a basic example would be like

//get html from page. store in variable $html;
$pattern = '#generic/part/of/url/(.+?)#i';
if (preg_match_all($pattern, $html, $matches)){
array_shift($matches);//take out first entry because it is entire match, which we dont need
print_r($matches);//show array structure

 

hi

 

thanks for the links...here are the example urls

 

http://omars.gmu.edu/items

 

When clicked on Paper: "The Center for Interactive Management," October 1981,it redirects us to http://omars.gmu.edu/items/show/2536....and when clicked on the http://hdl.handle.net/1920/5657 below the Identifier,a new page pops-up where the images/docs can be viewed....I need them to placed as thumbnails on the left of the title Paper: "The Center for Interactive Management," October 1981 in this page http://omars.gmu.edu/items....

 

similarly,when clicked on

Paper: "Major Impacts from Recent Applications of Interactive Management (April 1983-July 1988)",an identifier with linkhttp://hdl.handle.net/1920/5655 can be found down the page,when clicked redirects to the page with same url having images/docs/pdfs...same thing is expected to happen..getting an image/docs/pdfs and displaying them as thumbnail beside Paper: "Major Impacts from Recent Applications of Interactive Management (April 1983-July 1988)" in  http://omars.gmu.edu/items

 

I'm expecting a function or code that does the same thing dynamically for all the items on that webpage....the link provided in the identifier cannot be accessed now as the server is down...

 

 

Thanks,

Maddali

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.