Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
http://api.drupal.org/api/function/theme_image/5
It might not be completely obvious to all that in order to specify a URL as the image path, the 5th argument needs to be set to TRUE. The documentation does not currently specify this.
Comment | File | Size | Author |
---|---|---|---|
#20 | theme_image_getsize-new4-225950-D6.patch | 902 bytes | daniels220 |
#18 | theme_image_getsize-new3-225950-D6.patch | 896 bytes | daniels220 |
#16 | theme_image_getsize-new2-225950-D6.patch | 630 bytes | daniels220 |
#13 | theme_image-getsize-new-225950-D6.patch | 795 bytes | daniels220 |
#11 | theme_image-getsize-225950-D6.patch | 808 bytes | daniels220 |
Comments
Comment #1
drummComment #2
brendoncrawford CreditAttribution: brendoncrawford commentedCan we get some love on this?
Comment #3
webchickMoving to documentation component, and moving down to D6. I think #238681: theme_image() not evaluating properly? is a better approach for D7.
Comment #4
jhodgdonLooking at the code, it looks like in Drupal 5/6, theme_image() only works if either getsize is FALSE or if the URL is relative to the base path and it can figure out the image dimensions. The original report is wrong, IMO -- it needs to be $getsize=FALSE to work with absolute URLs.
It is also still working the same in Drupal 7. The issue mentioned above has been closed as a "won't fix".
So this needs to be documented in Drupal 7, 6, and 5.
Comment #5
jhodgdonCould be a good novice project.
Comment #6
mgriego CreditAttribution: mgriego commentedI assume this is what you're looking for... My reading of the code was the same that $getsize needs to be false for fully qualified URLs to work, so I added the appropriate parameter comments for D5/6/7.
Comment #8
jhodgdonCan you rework this a bit? (I"m talking about the D7 patch, didn't look at the others yet -- let's get that one right first):
- We don't usually use all-caps -- it's a bit shouty. Just say "This must be set..." rather than "This MUST be set".
- There is no $path in the D7 args - it's a component of the variables array
- We should probably mention on the 'path' component as well that you need to set the 'getsize' component to FALSE if you use a full URL
Also, please read the instructions below the file attach about file names for D6/D5, which will avoid having the test bot complain.
Comment #9
amateescu CreditAttribution: amateescu commentedThis doesn't make sense anymore for D7 because the $getsize component was removed in #908282: Remove unnecessary I/O from theme_image().
Comment #10
jhodgdonThanks for checking into that -- you are correct. So we just need a Drupal 6 patch.
Comment #11
daniels220 CreditAttribution: daniels220 commentedHere's my stab at a D6 patch.
Comment #12
jhodgdonMissing a . at the end of the sentence.
false -> FALSE
Also, when you attach a patch, please set the status to "needs review", so that we know there's something to review, thanks!
Comment #13
daniels220 CreditAttribution: daniels220 commentedThanks for the feedback. New patch attached.
Comment #14
jhodgdonpatch header needs fixing - wrong file names, can't apply
Comment #15
jhodgdonActually, the text here is not correct. You don't need to set $get_size to FALSE if a URL is used, you need to supply the sizes yourself because $get_size will be ignored... correct?
Comment #16
daniels220 CreditAttribution: daniels220 commentedNot sure on the wording for $getsize, but I noted that it is ignored if $path is a full URL.
Comment #17
jhodgdonUgh, my mistake.
I looked closer at the code and I think you do need to set $get_size to FALSE, because if it's set to TRUE and is_file() returns FALSE, nothing will get printed. Yuck! who wrote this code?!?
Comment #18
daniels220 CreditAttribution: daniels220 commentedYou are indeed right. New patch attached with slightly more noticeable warnings about needing to set $getsize = false.
Comment #19
jhodgdonHmmm.
- In 2nd sentence, url -> URL.
- I don't think that 2nd sentence is accurate. It looks to me like if $getsize is TRUE, nothing at all is returned (not an empty IMG tag).
Maybe this should mention that TRUE is the default? Also, there should be a blank line between the @param and @return.
Comment #20
daniels220 CreditAttribution: daniels220 commentedFixed all that.
Comment #21
jhodgdonNow we're talking. Looks good. Thanks for the repeat patching.
Comment #22
Gábor HojtsyGreat, committed, thanks.