Answers.Body: <p>Try using:</p>
  
  <pre><code>{{ gist.gistImage.first().getUrl('gistUnit')|replace({'http': 'https'}) }}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-03T17:36:03.033Z
Answers.Text: even better: `replace({'http://': 'https://'})` so you won't map `https://` to `httpss://`
Answers.UserDisplayName: Marion Newlevant
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-03T04:01:25.440Z
Answers.LastActivityDate: 2014-11-03T04:01:25.440Z
Answers.UserDisplayName: Brad Bell
Body: <p>I have a template that displays in both http and https environments. When pulling my images for the https environment I need to be able to change the URL to https:// from http://. I tried</p>
  
  <pre><code>{{ gist.gistImage.first().getUrl('gistUnit')|replace({'http': https}) }}
  </code></pre>
  
  <p>based on the documentation here twig.sensiolabs.org/doc/filters/replace.html</p>
  
  <p>Not working. Is this because getURL() gets processed after the filter?</p>
  
Tags: <https>
Title: Using Twig's replace filter with getURL()
ThreadText: # Using Twig's replace filter with getURL()
  
  (Asked by: username_0 on 2014-11-03)
  
  I have a template that displays in both http and https environments. When pulling my images for the https environment I need to be able to change the URL to https:// from http://. I tried
  
  ```
  {{ gist.gistImage.first().getUrl('gistUnit')|replace({'http': https}) }}
  
  ```
  
  based on the documentation here twig.sensiolabs.org/doc/filters/replace.html
  
  Not working. Is this because getURL() gets processed after the filter?
  
  **Tags:** https
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-11-03. Score: 3 | Accepted answer
  
  Try using:
  
  ```
  {{ gist.gistImage.first().getUrl('gistUnit')|replace({'http': 'https'}) }}
  
  ```
  
  > **Comments:**
  > **username_2**: even better: `replace({'http://': 'https://'})` so you won't map `https://` to `httpss://`  
  
  ---
  
  