Add a non-themeable replacement for theme_image() and theme_image_style()

Created on 25 May 2013, about 12 years ago
Updated 18 August 2025, 6 days ago

theme_image() could be replaced with an equivalent, non-themeable, alterable function (like l()) and achieve the same functionality with less function calls.

theme_image_style() isn't even a "real" theme function, it just prepares a few variables and passes them to theme('image') without doing any of its own rendering of markup.

So currently, to render an image tag with a style we do this:

theme('image_style') -> theme_image_style() -> theme('image') -> theme_image()

When we could just do this:

render_image_style() -> img()

Aside from just wanting to simplify things a bit, I did some preliminary xhprof profiling (by just calling theme_image() and theme_image_style() directly and not modifying anything else) and found that for an image heavy page (~200 images) bypassing theme() shaved about 30ms off total page load times (or 1.2%).

Related

#1986116: Improve performance by replacing very small and simple templates and theme function with "Markup Utility Functions" β†’
#1899454: [meta] Refactor Render API β†’
#1825090: Remove theme_html_tag() from the theme system β†’

πŸ“Œ Task
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

theme system

Created by

πŸ‡¦πŸ‡ΊAustralia thedavidmeister

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

  • stale-issue-cleanup

    To track issues in the developing policy for closing stale issues, [Policy, no patch] closing older issues

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thank you for creating this issue to improve Drupal.

    We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

Production build 0.71.5 2024