webent Posted August 17, 2008 Share Posted August 17, 2008 Was wondering if anyone could point me in the right direction on how I would go about changing the calling location of images to their secure location after the page in which contains the images is called from a "require"? Here is my require... <? require $url . "/includes/header.inc"; ?> Now is there a way to parse that include file before it is output, to change any "<img src="http://" to "<img src="https://"? Link to comment https://forums.phpfreaks.com/topic/120060-solved-change-all-quotimg-srcquot-to-quothttpsquot-after-quotrequirequot/ Share on other sites More sharing options...
MasterACE14 Posted August 17, 2008 Share Posted August 17, 2008 <?php $protocol = "http://"; if($protocol == "http://") { str_replace($protocol,"https://"); } ?> Link to comment https://forums.phpfreaks.com/topic/120060-solved-change-all-quotimg-srcquot-to-quothttpsquot-after-quotrequirequot/#findComment-618475 Share on other sites More sharing options...
webent Posted August 17, 2008 Author Share Posted August 17, 2008 Thank you MasterACE14 for your response... I know how to use str_replace() though, my problem is, parsing the include file before it is output... Link to comment https://forums.phpfreaks.com/topic/120060-solved-change-all-quotimg-srcquot-to-quothttpsquot-after-quotrequirequot/#findComment-618476 Share on other sites More sharing options...
MasterACE14 Posted August 17, 2008 Share Posted August 17, 2008 not sure what you mean. But maybe your after file_get_contents(); ? Link to comment https://forums.phpfreaks.com/topic/120060-solved-change-all-quotimg-srcquot-to-quothttpsquot-after-quotrequirequot/#findComment-618478 Share on other sites More sharing options...
webent Posted August 17, 2008 Author Share Posted August 17, 2008 Yeah, that might work, I'm not sure, I'll try it... Link to comment https://forums.phpfreaks.com/topic/120060-solved-change-all-quotimg-srcquot-to-quothttpsquot-after-quotrequirequot/#findComment-618479 Share on other sites More sharing options...
webent Posted August 17, 2008 Author Share Posted August 17, 2008 Ok, it worked, thanks MasterACE14... $completeFilePath = $preurl . "/includes/header.inc"; $handle = file_get_contents($completeFilePath); $search = array("<img src=\""); $replace = array("<img src=\"" . $otherurl . "/"); $fields = str_replace($search,$replace,$handle); echo $fields; Link to comment https://forums.phpfreaks.com/topic/120060-solved-change-all-quotimg-srcquot-to-quothttpsquot-after-quotrequirequot/#findComment-618486 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.