0

I have to re-make a part of my page. This is part of code that is making my link :

$downloadLinks .= '<li><a onclick="document.getElementById(\'last-crop-resize\').parentElement.style.backgroundColor=\'lightgreen\';document.getElementById(\'last-crop-resize\').innerHTML=this.href" target="_blank" href="'._CONFIG_SITE_PROTOCOL . '://' . file::getFileDomainAndPath($file->id, $file->serverId, true) . '/' . PLUGIN_DIRECTORY_NAME.'/images/scripts/resize_image.php?m=middle&f='.(int) $file->id.'&w='.$linkWidth.'&h='.$linkHeight.'"><i class="entypo-right"></i>JPG '.$linkWidth.' x '.$linkHeight.' px</a> </li>';

On the screen I am getting some thing like this:

https://localhost/plugin/images/scripts/resize_image.phpm=middle&f=16788&w=390&h=276

All I am douing is selecting it on click.

Now I need to change this part so that my screen output is this :

    {*<img src="https://localhost/plugin/images/scripts/resize_image.php
    m=middle&f=16788&w=390&h=276" 
    alt="" title="" width="390" height="276" vspace="20" hspace="20" border="0"
    style="width:390px;height:276px;margin-top:0px;margin-bottom:0px;
    margin-left:0px;margin-right:0px;border:0px solid black;" class="" />*}

I've tried using ASCII for escaping inside of a innerHTML , but as soon as I try to place <img my output start's breaking.

So just to add a bit more info :

  1. It is not redirecting.

  2. And all the functionality I need is => select all on click, so that I can copy the output.

Is this possible?

user3350597
  • 471
  • 1
  • 4
  • 14

3 Answers3

0

Your question is unclear on what you're trying to achieve, but I think you are trying to use an image as a link?

If so here is what you need:

<a href="https://localhost/plugin/images/scripts/resize_image.php
        m=middle&f=16788&w=390&h=276">
    <img src="https://localhost/plugin/images/scripts/resize_image.php
    m=middle&f=16788&w=390&h=276" 
    alt="" title="" width="390" height="276" vspace="20" hspace="20" border="0"
    style="width:390px;height:276px;margin-top:0px;margin-bottom:0px;
    margin-left:0px;margin-right:0px;border:0px solid black;" class="" />
</a>

Let me know if this helps

Grizzly
  • 5,873
  • 8
  • 56
  • 109
0

I am not sure but I think this is what you are looking for.

you are allowed to nest an img element in an a tag

<a href="https://localhost/plugin/images/scripts/resize_image.php?m=middle&f=16788&w=390&h=276"> <img src="https://localhost/plugin/images/scripts/resize_image.php?m=middle&f=16788&w=390&h=276" 
    alt="" title="" width="390" height="276" vspace="20" hspace="20" border="0"
    style="width:390px;height:276px;margin-top:0px;margin-bottom:0px;
    margin-left:0px;margin-right:0px;border:0px solid black;" class="" /></a>
happymacarts
  • 2,547
  • 1
  • 25
  • 33
0

I managed to get it to work. My question title was bad so I've change it. All I needed to do is to change innerHtml and not href. Don't know what I was thinking. This is my solution :

$downloadLinks .= '<li><a onclick="document.getElementById(\'last-crop-resize\').parentElement.style.backgroundColor=\'lightgreen\';document.getElementById(\'last-crop-resize\').innerHTML=\'{*<&#127;img src=&quot;\'+this.href+\'&quot; alt=&quot;&quot; title=&quot;&quot; width=&quot;'.$linkWidth.'&quot; height=&quot;'.$linkHeight.'&quot; vspace=&quot;20&quot; hspace=&quot;20&quot; border=&quot;0&quot; style=&quot;width:'.$linkWidth.';height:'.$linkHeight.';margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;border:0px solid black;&quot; class=&quot;&quot; &#47;>*}\'"; target="_blank" href="'._CONFIG_SITE_PROTOCOL . '://' . file::getFileDomainAndPath($file->id, $file->serverId, true) . '/' . PLUGIN_DIRECTORY_NAME.'/images/scripts/resize_image.php?m=middle&f='.(int) $file->id.'&w='.$linkWidth.'&h='.$linkHeight.'"><i class="entypo-right"></i>JPG '.$linkWidth.' x '.$linkHeight.' px </a> </li>';

The output is :

{*<img src="https://localhost/plugin/images/scripts/resize_image.php
m=middle&f=16788&w=390&h=276" 
alt="" title="" width="390" height="276" vspace="20" hspace="20" border="0"
style="width:390px;height:276px;margin-top:0px;margin-bottom:0px;
margin-left:0px;margin-right:0px;border:0px solid black;" class="" />*}

Thanks to everyone who tried to help.

user3350597
  • 471
  • 1
  • 4
  • 14