1

We have a number of spots throughout our experience where there are hard-coded absolute references to images and we are looking to change that. An example would be a reference to an image src of http://www.blahblah.com/images/image1.jpg . This is a no no, but it happened way back quite a bit and not just for images, for videos, files, CSS, etc as well. We are now moving to https sitewide so these all cause mixed-content issues, so we need to fix... but there are A LOT of them so by hand would take a while.

With that as background, does anyone have suggestions as to the best way to find and replace the content? For the most part, we could really just change http://www.blahblah.com to https://www.blahblah.com OR just remove http://www.blahblah.com and leave the reference as /images/image1.jpg. In our case, both should work.

  • If they're not already managed, for editor-managed images consider replacing the references with Multimedia Component Links, which templating could convert to your preferred format. For the sake of time, you could perhaps handle the format difference in the web application or templating until all the individual fixes are done. – Alvin Reyes Jun 20 '18 at 8:49
3

Although I agree with what Vipin is saying, I would like to summarize this issue and proposes solutions. Although Event System is one option, it will be too much of a strain on a system since it will be executed on every component save/update event, to what I guess not that much components.

If you want to fix components once and for all, you should use core services to identify them and update. But please be aware of the following:

  • although you can parse XML source of component to replace one URL with another, you should be careful with handling rich text fields (which are stored as XHTML in component)
  • sometimes its hard to identify type of component field in source of component since its XML, so tread carefully.
  • be vary of workflow and translation! They can lock your component, and if some component is in the process of translation, you will have to redo your update on these ones after they are returned from translation.
1

We also had image url's in the content, but we had configured publishing templates to take the core part (http://actualdomain) from a publication property. So, we had the relative path in the components and then clubbed that with the property on the publication to get the full path on the published content. If that is the setup that you also have, then you can change it and then republish the content and it will fix it.

If that is not the case, then there is no easy way. You can write a publishing template in which you can add the code to check the url and if it sees this url during any publishes it will fix it to the right one. Another option will be to use core service and write a utility which looks up all the components which can have image urls and replace them once and for all with the correct one and republish them.

Both option will work, but an elegant way long term will be to keep the core url configurable in the publication property as I described

1

As @Vipin highlighted one of the options you can use core service to find and replace the text on the components and republish.

I have done power page to find and list and confirm to replace the text on the components and publish all components using core service.

I hope it helps.

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.