1

In order to generate full path of images(URL) on views for rest endpoint on my decoupled Drupal project I'm using Image Url Formatter module, everything works correctly until I decide to put the website on HTTPS, In console I see
Loading mixed (insecure) display content “http://core.domain.com/sites/default/files/styles/874x492/public/gallery/2017-01/1-907331.JPG?itok=MKfQSWFh” on a secure page

it's because this formatter return HTTP Instead HTTPS for image URLs.

In the situation like this that the websites should work on HTTPS and HTTP both, I advise my team using //domain.com instead of http://domain.com or https://domain.com in all endpoint URLS

Now I looking for a solution to return all images URL from http://.... to //... . if I had few views I could benefit REWRITE feature of view but I have a lot of views rest export endpoint.

What is your solution for this requirement?

1

Doing a quick test, works fine with HTTPS

enter image description here

Views REST XML

enter image description here

Views REST Json

enter image description here

All of the above is using FULL URL

enter image description here

Perhaps someone set it to Absolute file path, which will give you /path/image.jpg (with out the $base_url). Then in some template file they did http://example.com{{ field.image.content }}

update

using template_preprocess_image_formatter() is another solution to change the template formatter of the image.

  • as I mentioned in the question I know I can do this for each view one by one, but there are several view and I looked for a global solution, – Yusef Mohamadi Jan 21 '17 at 10:26
  • @zhilevan and what I am saying is that it should've worked had your people set things up properly. Why do you have a lot of views? Are you not using Contextual Filters? – No Sssweat Jan 21 '17 at 10:34
  • I think create working with template_preprocess_image_formatter() is better solution and there, replace all http:// with // – Yusef Mohamadi Jan 21 '17 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.