I've almost got the image.module working just right.

The problem is, the "Original Image" view breaks my layout... bad. I still want to keep the original image size as a viewable option, but is has anyone figured out a way to have it open in a blank page or another window instead?

Comments

zach harkey’s picture

Ok, I think it might be possible to do this with the sections.module. I created a separate theme with a page.tpl.php template layout that can handle the "original image" size (no sidebar, no fixed width, etc.), but I can't seem to get it to kick in when I load an original image.

Using node 11 as an example, the path when viewing an original image is:
/node/11?res=original

In "administer > settings > sections ", I can't figure out what to enter under "Pages". I've tried "?res=original", "*original", and every combination I can think of.

I know the module is working correctly because when I enter "node/*" the section template kicks in perfectly.

I know $#@! about regex so I might be missing something obvious, but I've applied everything I can find that works with the blocks.

Anyone have any ideas, or is sections.module not even the right direction to achieve these results?

: z

zach harkey’s picture

Well, I tried my best to make the sections.module do this but no dice. Any ideas?

: z

sepeck’s picture

I took a very quick look and did not see an obvious way to do this. You have 2 real choices.

Do it through the theme you are using, of which I don't see a way to differenciate between link types. Perhaps some custom stuff with a phptemplate based theme .....

Add/change code in the image module. My cursory glance through the image module did not discover where the original image code link was generated. So this may not be easy.

-sp
---------
Test site...always start with a test site.
Drupal Best Practices Guide

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

iraszl’s picture

I'd like to this exact same thing in 4.6. Can you help me how to go about it?
---
http://creativebits.org

iraszl’s picture

Bump. Any solution to this?
Is there no way the new image.module will allow the original size images to be viewed in a pop-up? It would be essential for fixed width themes!
---
http://creativebits.org

tatonca’s picture

So I'm going to assume based on the date of the original post that we might be talking about the original image.module as oppose to the new one walkah has been working on...

looking at the code, where you want to tweak it is in the image_link() function here:

// Add links to an image node.

  if ($type == "node" && $node->type == "image") {
    foreach(explode(",", variable_get("image_default_resolutions", "640x480,800x600,1024x768,1600x1200")) as $v) {
      $max_dim = split("x", $v);
      if ($node->width > $max_dim[0] || $node->height > $max_dim[1]) {
        $links[] = l($v, "node/$node->nid", array(), "res=$v");
      }
    }
    $links[] = l(t("original image"), "node/$node->nid", array(), "res=original");

that last line is the key. This adds the link to the original image to the array of links using drupals built in link creation function l () (that's an 'L', lower case ;) ). You can check out how that works here

http://drupaldocs.org/api/4.5/function/l

An easy way - not pretty mind you - would be to just add the target=\'_blank\' in place of the blank array ('array()') argument - this is the attributes argument for the l function.

The more difficult way would be to completely rewrite that link using some inline java script code that calls a .cab containing standard java browser window box stuff...

$links[]="<a href=\"#\" on click=\"do some stuff/load some java /whatever\">"

In this instance you will have do a bunch of work to figure out what the imageurl is to pass to the java script ect...

If I had more time I would dig into this more, as it is functionality I too would find interesting... however I'm pretty tapped out right now... :(

Hope this helps,

Cheers
~Tat~

iraszl’s picture

Thanks for the guidance, but I was actually looking for a solution for the new image.module (for 4.6) as I stated in my message above. Hopefully walkah will have time to give some hints on this one.
---
http://creativebits.org

tatonca’s picture

...still not sure what the original poster was using though - I probably should have pressed reply on the first post so mine nested more appropriately... ;)

zach harkey’s picture

Original poster here; using 4.5.2

4.6 is not out yet, and even when it is out, it's going to be a while before many of us who depend on certain modules are going to be able to depend on this for professional use, so let's focus this thread on a solution for the current release.

: z

iraszl’s picture

4.5.2 is history. 4.6 is around the corner. it doesn't make sense spending time on 4.5.2 hacks anymore. let's focus this thread on 4.6 ;)
---
http://creativebits.org

zach harkey’s picture

The whole reason for the thread is because I need a solution now, not 'around the corner' when 4.6 is out and all the modules I'm dependent on are updated and working.

This is for a real-life, paying client who can't understand why I can't duplicate the functionality found in so many other gallery systems (i.e. the full size version opening on its own page, instead of wrecking his beautiful fixed-width page design).

So please don't argue the validity of finding a solution that works with the current version, it's not helpful.

: z

iraszl’s picture

tatonca’s picture

...Speaking mostly to zachharkey, so that when other 4.5.x users are searching the forums and get to this node they can at least find an answer after swimming through the FUD...

[~Tat~ cops a wicked a** chesire grin]

zach harkey’s picture

I have to admit, your solution is a little advanced for me. I seem to be hung up in the documentation for the l() function. I'm still trying though.

-zach

: z

Stefan Nagtegaal’s picture

$links[] = l(t('original image'), "node/$node->nid", array('target' => '_new'), 'res=original');

this should work...

iraszl’s picture

Stefan, where do i paste this code please! Sorry to be so bumb! :)
---
http://creativebits.org

sepeck’s picture

Looks like line 224

-sp
---------
Test site...always start with a test site.
Drupal Best Practices Guide

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

iraszl’s picture

cool. just one last question. which file? :)
---
http://creativebits.org

sepeck’s picture

image.module

-sp
---------
Test site...always start with a test site.
Drupal Best Practices Guide

-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide

zach harkey’s picture

cool. just one last question. which file? :)

I'm glad you asked.

-zach

P.S. I wonder how small these threaded boxes can get.

: z

iraszl’s picture

Cool! Got it working under 4.5.2. But the image opens within the theme. We'd like to open just the image, not an html. Is that possible?

The ultimate would be to direct the original image link to a new template page that is non fixed width. How to do that?

---
http://creativebits.org

zach harkey’s picture

i experimented and came up with a slight variation on stefan's line:

instead of

$links[] = l(t('original image'), "node/$node->nid", array('target' => '_new'), 'res=original');

try

$links[] = l(t('original image'), "node/$node->image_path", array('target' => '_new'));

It will output a link that links directly to the image.

-z

: z

iraszl’s picture

I think it will work if the clean urls are on. How would this hack look like if the clean urls are not on?

Right now it gives an unnecessary "/?=node" part like this:
http://mydomain.com/?q=node/images/70ea0d7a8601137d79eedaeecb741f31-63.jpg
---
http://creativebits.org

zach harkey’s picture

My bad, I forgot to strip off the 'node/' part,

Should be

$links[] = l(t('original image'), "$node->image_path", array('target' => '_new'));

: z

iraszl’s picture

Sorry to be such a pain in beep, but with clean urls off i still get an unnecessary "?q=". However at least the /node is gone. :)
---
http://creativebits.org

zach harkey’s picture

No sweat, you're not a pain at all.

In your case, I'd give up on this l(); function. Instead just bust it out in straight html and be done with it...

So, to recap in case you have gotten lost. Ignore everything above and instead do this:

In image.module (somewhere around line 227), replace:

$links[] = l(t('original image'), "node/$node->nid", array('target' => '_new'), 'res=original');

with this:

$links[] = '<a href="/'.$node->image_path.'" target="new" title="Original image (opens in new window)">original image</a>';

This will bypass drupal's ?q= shenanigans altogether.

If this works, please let me know. But I tested it with clean URLs off and it works fine for me. By the way, I'm sure you have your reasons but I just have to ask, why don't you turn clean urls on? They're so... clean.

: z

iraszl’s picture

Thank you very much! We've implemented your solution on 4.6. You can see it here, it works great:
http://creativebits.org/node/1124
---
http://creativebits.org

lustratus’s picture

I had to use this solution:

$links[] = l(t('view original'), 'files/'.$node->images['_original'], array("target"=>"_blank"));

jeforma’s picture

would there be a way to make the "View original" Link a image instead of just plain text?? I tried everything to make it a image but it just won't work...

Can somebody lead me on a trace...??

iraszl’s picture

You could try to create a new language and replace the words with an image tag. Never tried it, but you may want to give it a try.

---
http://creativebits.org

jeforma’s picture

uhhh, i dont get what you mean, can you elaborate on that? How could I include that in the image.module file??

iraszl’s picture

You know you can have language translations in Drupal. You create a new language and you can replace all strings in your Drupal site to other strings. For example you can replace "recent posts" to "track changes". The same way you may be able to change "recent posts" to an img tag i guess. Never tried it...
---
http://creativebits.org

jeforma’s picture

uhh, yah i think i understand what you mean, ill try to take a look at it, but i dont think i will manage to get it right, as I am prety much a newbie when it comes to php strings...

marlowe’s picture

I did some hack at image module, you could check it at http://www.nodigas.com.ar/node/233 The hack is explained in spanish at http://www.nodigas.com.ar/files/cambios_image.txt, just two changes:

1. Code change at node_image_content function, just to render a javascript for a new window.
2. Code change at image_link, to call another javascript for open a new window with image at original resolution.

luck..//

gordon’s picture

If you want to view the image directly you can do this by using image/view/{nid}/original with the new one. with the old version instead of original you need to put image/view/{nid}?res=original

I think that is correct for 4.5 but not 100%

--
Gordon Heydon
Heydon Consulting

--
Gordon Heydon

Anonymous’s picture

I know this issue has been lying around for a while, but this is what I did to the image.module file to make the 'original' link direct users to just an image with nothing else:

on line 242 (this is version 1.1) change:

$links['image_size_original'] = array('title' => t('original'), 'href' => 'node/'. $node->nid, 'query' => 'size='. IMAGE_ORIGINAL);

TO:

$links['image_size_original'] = array('title' => t('original'), 'href' => 'image/view/' . $node->nid. '/_original');

mianghe’s picture

Thanks kevee, it's an easy way and works perfectly.

dimitris_s’s picture

Thanks Kevee, that worked for me too - drupal 5.1-

jgmyers’s picture

Your solution works great to present the image by itself in the browser window, but it fills the parent browser window or tab. I'd like for the URL that is built for "original" have a target of _new or _blank? Anybody have any ideas?
Thanks