Monday, November 08, 2010 at 12:05 AM.

system.verbs.builtins.radio.images.systemImageUrl

on systemImageUrl (imgpath, adradrimage=nil, flFileUrl=false) {
	<<Changes:
		<<1/22/02; 8:17:35 PM by JES
			<<Optimization: Don't call radio.userInterface.saveImages here. Images are now installed by radio.thread.agents.installer.
		<<1/9/02; 12:37:00 PM by PBS
			<<user.radio.prefs.flUseFileUrls can over-ride the flFileUrl parameter. This way someone using Mozilla or Netscape on OS X can say no to file:/// URLs.
		<<11/25/01; 3:16:26 AM by JES
			<<Implemented a workaround for the character-case issue on Windows, since converting to a filespec doesn't fix the character-case of the filename.
		<<11/23/01; 9:07:51 PM by JES
			<<Convert the image file path to a filespec, so we have the correct character-case.
		<<9/2/01; 11:38:27 PM by JES
			<<Pass the URL through radio.images.imageFlowBottleneck before returning it. Done in a try block, since imageFlowBottleneck will error outside the website framework context.
	bundle { //PBS 01/09/02: check pref, possibly over-ride flFileUrl
		if flFileUrl {
			if not user.radio.prefs.flUseFileUrls {
				flFileUrl = false}}};
	if imgpath beginswith "/" {
		imgpath = string.delete (imgpath, 1, 1)};
	local (origimgpath = imgpath);
	local (folder, adr);
	bundle { //set folder and adr
		<<folder = radio.userInterface.saveImages ()
		folder = radio.file.getSubFolder (radio.data.folderNames.wwwSystemSubfolderName + "/images/", false);
		adr = @radio.userInterface.images;
		local (ctparts = string.countfields (imgpath, "/"), i, s);
		for i = 1 to ctparts - 1 {
			s = string.nthfield (imgpath, "/", i);
			folder = folder + s + file.getpathchar ();
			adr = @adr^.[s]};
		imgpath = string.nthfield (imgpath, "/", ctparts);
		adr = @adr^.[imgpath];
		if adradrimage != nil {
			adradrimage^ = adr}};
	local (extension);
	case getbinarytype (adr^) {
		'gif ' {
			extension = ".gif"};
		'GIFf' {
			extension = ".gif"};
		'JPEG' {
			extension = ".jpg"}};
	local (f = folder + imgpath + extension, url, pc = file.getPathChar ());
	if system.environment.isMac { //MacOS -- convert to a filespec to fix the filename's character-case
		f = string (filespec (f))}
	else { //workaround for windows: use fileloop (f in f) {} to fix the filename's character-case
		fileloop (f in f) {}};
	origimgpath = string.replaceAll (string.delete (f, 1, sizeOf (user.radio.prefs.wwwfolder + radio.data.folderNames.wwwSystemSubfolderName + "/images/")), pc, "/");
	if flFileUrl {
		<<return (html.getFileUrl (f))
		url = html.getFileUrl (f)}
		<<url = file.fileToUrl (f)
	else {
		url = "/" + radio.data.folderNames.wwwSystemSubfolderName + "/images/" + origimgpath};
	try { //this fails if called outside the website framework context
		url = radio.images.imageFlowBottleneck (f, url)};
	return (url)}
<<bundle //test code
	<<local (pt)
	<<new (tabletype, @pt)
	<<new (tabletype, @pt.radioResponder)
	<<pt.radioResponder.flsamemachine = false
	<<html.setpagetableaddress (@pt)
	<<webbrowser.displaytext (imageUrl ("icons/brain"))
<<bundle //more test code
	<<systemImageUrl ("weblogDefault/userland", flFileUrl:true)



This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.