Here is a patch for image_get_random() function accept the second parameter ($tid) correctly.

Comments

Robrecht Jacques’s picture

Assigned: Unassigned » Robrecht Jacques
StatusFileSize
new1.9 KB
  • This is issue is still valid: image.module doesn't implement what it says it does.
  • Impact is minimal because I can't find any usages of "image_get_random", except in the blocks of "image module" where $tid is not used (since it can't be set anyway)

Attached is an updated patch, that also implements the same in "image_get_latest".

Optionally:

  • I'm wondering if "image_get_latest" can be used in "image_page" where a similar db_query is done to get the latest image of a set of $tids. The "image_get_latest" (and why not "image_get_random" too) should then be changed to accept a list of $tids, eg with a if(!is_array($tid)) $tids =array($tid); else $tids = $tid;
  • Only problem with this is that the "ORDER BY" is different in "image_get_latest" (changed DESC) and "image_page" (n.sticky DESC, n.created DESC). Is there a reason for this?
Robrecht Jacques’s picture

Status: Needs review » Reviewed & tested by the community

I've tested that this works. It surely doesn't break anything (because $tid is not used).

walkah’s picture

Status: Reviewed & tested by the community » Fixed

fixed, cvs.

phildu’s picture

i found a bug...
the node add image function disapear ???
whith your patch

Anonymous’s picture

Status: Fixed » Closed (fixed)
seanr’s picture

Version: » 4.6.x-1.x-dev
Status: Closed (fixed) » Active

This still needs to be fixed in 4.6

Robrecht Jacques’s picture

Assigned: Robrecht Jacques » Unassigned
drewish’s picture

Status: Active » Closed (fixed)

This version is no longer supported. If this issue is occurring with a more recent version please open a new issue.