Passing image url parameter

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
avoosh
Forum Commoner
Posts: 27
Joined: Tue Oct 06, 2009 7:30 pm

Passing image url parameter

Post by avoosh »

Hi,
I am trying to make this static code into dynamic. I can not get it to work with the title parameter. It does pass the 2 (link) parameter but only the root link. The 3rd parameter is broke. I would appreciate anyone's help


Static
<a href="http://www.polyvore.com/cgi/add?title=T ... =IMAGE_URL">
<img src="http://cdn.polyvore.com/rsrc/img/favicon.png">
</a>

Code: Select all

     
  
  <a href="#" onclick="handleImageClick( 'http://www.polyvore.com/cgi/add?title=title&url=url&imgurl=imgurl' ); return false;"  target="_blank">
<img src="http://cdn.polyvore.com/rsrc/img/favicon.png" border="0">
</a>
 
<script type="text/javascript">
function handleImageClick( imgUrl ) {
  var path = 'http://www.polyvore.com/cgi/add?';
  path += 'title=' + encodeURIComponent( document.title );
  path += '&url=' + encodeURIComponent ( document.location.href );
  path += '&imgurl=' + encodeURIComponent ( imgUrl );
  window.open(path);
 }
 </script>
ell0bo
Forum Commoner
Posts: 79
Joined: Wed Aug 13, 2008 4:15 pm

Re: Passing image url parameter

Post by ell0bo »

What is the resulting path that get generated? The code looks correct, but if I can see what the result is perhaps I can have a better idea.

I do notice you're passing in "http://www.polyvore.com/cgi/add?title=t ... url=imgurl" instead of "http://cdn.polyvore.com/rsrc/img/favicon.png" to the function.
avoosh
Forum Commoner
Posts: 27
Joined: Tue Oct 06, 2009 7:30 pm

Re: Passing image url parameter

Post by avoosh »

Hi, thanks for answering, the resulting output is

http://www.polyvore.com/cgi/add?title=A ... l%3Dimgurl

I'm really looking forward to getting this figured out.

thanks
ell0bo
Forum Commoner
Posts: 79
Joined: Wed Aug 13, 2008 4:15 pm

Re: Passing image url parameter

Post by ell0bo »

Your code is doing exactly what you wrote it to do. You are passing in 'http://www.polyvore.com/cgi/add?title=t ... url=imgurl' to the function and it's being appended into the imgurl part of the URL.
Post Reply