Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7655387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:30:12+00:00 2026-05-31T12:30:12+00:00

I would like to avoid browser cache on my images by appending the SVN

  • 0

I would like to avoid browser cache on my images by appending the SVN revision number after each images like this (in the same fashion than this answser):

<?php $v = getRevisionNumber() ?>
<img src="picture.jpg?v=<?= $v ?>" alt="">

Is there a way to do it automatically in Symfony 1.4 (like this for js/css, but with images instead)

Also, how can I do it for an image that is in a css file ?

#title {
    background-image: url(/images/title.png);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:30:14+00:00Added an answer on May 31, 2026 at 12:30 pm

    I found something interesting in the symfony tracker, for the version 1.3/1.4, there were a patch to automatically add a timestamp to all files in the web directory: http://trac.symfony-project.org/ticket/6135

    It has been reverted since, no idea why … (to intrusive?).

    Override the default asset helper

    Anyway, I think you have to create your own AssetHelper (copied all contents from the current one) and add & customize the patch #6135 into a lib/helper/CustomAssetHelper.php.

    But you can’t unload the AssetHelper because it is automatically loaded in the core: http://trac.symfony-project.org/browser/branches/1.4/lib/view/sfPHPView.class.php#L33 So there will be conflict since you will have duplicate function (in AssetHelper and CustomAssetHelper).

    Add a custom template engine

    The idea is to have a custom sfPHPView to redefine the loadCoreAndStandardHelpers to call your own asset helper (put it in lib/view/sfCustomPHPView.class.php):

    class sfCustomPHPView extends sfPHPView
    {
      /**
       * Loads core and standard helpers to be use in the template.
       */
      protected function loadCoreAndStandardHelpers()
      {
        static $coreHelpersLoaded = 0;
    
        if ($coreHelpersLoaded)
        {
          return;
        }
    
        $coreHelpersLoaded = 1;
    
        $helpers = array_unique(array_merge(array('Helper', 'Url', 'CustomAsset', 'Tag', 'Escaping'), sfConfig::get('sf_standard_helpers')));
    
        // remove default Form helper if compat_10 is false
        if (!sfConfig::get('sf_compat_10') && false !== $i = array_search('Form', $helpers))
        {
          unset($helpers[$i]);
        }
    
        $this->context->getConfiguration()->loadHelpers($helpers);
      }
    }
    

    To change the default sfPHPView, you need to add a module.yml in config/ or apps/frontend/config/ with the following contents (inspired from sfTwigPlugin):

    all:
      view_class: sfCustom
    

    Override all image_tag()

    As Yzmir Ramirez said, image_tag() calls image_path() which call _compute_public_path($source, 'images', 'png', $absolute);.

    In _compute_public_path function, before the last condition, you customize the query_string to add your own revision number (which will be define somewhere else – sfConfig for example):

    $file = sfConfig::get('sf_web_dir').$source;
    if ('images' == $dir && sfConfig::get('my_revision_number'))
    {
      $query_string .= sfConfig::get('my_revision_number');
    }
    

    It might be a bit complex but using this way, you can override image_tag function and add the version number you want without redefine all you image_tag() call.

    About image inside a CSS, it’s a bit more complex since you will have to parse css or write css in PHP. No idea about the best way to do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My company is performing a SVN repository migration and I would like to avoid
I would like to avoid redistributing .NET runtime if possible with my application since
I would like to avoid pickling of certain fields in an instance of a
When users preview a report I would like to avoid giving them the option
Problem There are data gaps that need to be filled. Would like to avoid
I would like to use following sql to avoid constructing sql dynamically: SELECT CommentID,
I would like the user to select the time in javascript and to avoid
I have a lot of code and would like to avoid posting it all
This question has been asked before, but I would like a little more detail
Would like to get a list of advantages and disadvantages of using Stored Procedures.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.