Link to home
Start Free TrialLog in
Avatar of RollinNow
RollinNow

asked on

Mask image filename and assign to a variable

I need to hide the filename on a page of image thumbnails.  Each page has 30 thumbnails

I'd prefer not to use cfcontent or cflocation because of overhead issues. How can I hide the filename but still give access to the thumbnail images? The filename needs to be a variable so it can vary from one website to another.

Here are a few code excerpts.

<cfset thumbpath = "/thumb/#Replace(ListRest(FilesInfo.FILEPATH,"\"),"\","/","all")#">
<cfset DISPLAY_FILENAME = "#REReplace(Right(FilesInfo.FILENAME,8),"[^0-9]","","ALL")#.#ListLast(FilesInfo.FILENAME,".")#">

<cfoutput Query="FilesInfo">
     <A HREF="/members/#DISPLAY_FILENAME#">
     <img src="#thumbpath#/#filename#.JPG">
</cfoutput>

I don't care about masking the filepath, just the filename.
Avatar of Plucka
Plucka
Flag of Australia image

RollinNow,

Why? What are you trying to achieve?

Regards
Plucka
Avatar of RollinNow
RollinNow

ASKER

There are multiple website domains running on the same IIS server, CF5. All pages are created dynamically and all have the same content and thumbnail images. Variables allow us to make the pages and url's look different but not the images. I want search engines to see different source image names for different websites, without having to duplicate the hundreds of thousands of thumbnail images for the different websites.
Ok,

The way to do it is to have an image src of a CFM temlate, then have that CFM template serve up the appropiate image

ie:

<img src="/image.cfm?siteId=3&imageId=24" />

The same image on a different site would be

<img src="/image.cfm?siteId=5&imageId=24" />

Google or anything else will see these as different images.
I don't see how that could work. There is no imageId per website that relates to an image. I think my setup may be a bit too cockeyed for your suggestion. I hope I'm wrong and you can point it out and I'm missing something simple. But you sure got my interest, that is, the idea of using a cfm module in place of the img src. I don't think I've ever seen that before. Maybe you can stay with me on this and show me how it could work because I'm not getting it yet. I think it would be best if I give you some background on what I'm doing with the page variable, that is, the keyword.

My hope was to name the images from a list of popular search engine keywords we store in a database in comma delimited format. The keyword variable is readily available on each page and page to page. We use a cfm module to  populate the pages, depending on the website and the place the keyword resides in the list. So, each page has a theme, based on a keyword.

As an example, let's say one Category on our website is "DVD MOVIES". There may be many File Areas under that Category, with themes or keywords used to represent content of the same pages, per website. File Areas under "DVD MOVIES" will pull a keyword from a list of keywords such as, "movies on dvd, buy dvd movies, dvd movie releases". Each page has one keyword selected from that comma delimited keyword list. The list is much larger of course. The page keyword is used for the meta title, part of the meta description, alt, and text in the body of the page, anywhere on the page to make that page go with the theme of the keyword. The keyword is also used on the calling page to create the URL for the File Area, which changes based on the keyword, so that each website offers a different URL for the same File Area, such as:

http://www.domain1.com/download/dvd/movies-on-dvd1.htm
http://www.domain2.com/download/dvd/buy-dvd-movies1.htm.

So, with the example above, you can see the two domains use different URL's for the same page, and different titles, alt tags, etc. The image thumbnail names need to coincide with the page keyword.

Keywords are served based on the website ID and the where they keyword resides in the keyword list.  For a reference on these keywords, please see:

https://www.experts-exchange.com/questions/21905467/Website-OFFSET-VALUELIST-HELP.html

If you believe I could create another module such as your suggested "image.cfm" to name the images from the keyword variable, please let me know, give me an example if you will, or discuss it with me a bit so I can catch on. Or ask me any questions and I'll see if I can answer.

I hope that makes sense, and you can tell me that your example will still work, and you’ll show me how. I sure do appreciate your help!
Yes,

My idea would still work. You just need to pass some reference to the image and some random bits so that the URL is different.

ie

<img src="/image.cfm?image=bluefox.jpg&random=#randRange(1,100)#" />

This way the image would always have a different url, but won't cache in the browser, so passing some reference to the site your in would be better.

perhaps.

<img src="/image.cfm?image=bluefox.jpg&url=#CGI.SERVER_NAME#" />
the image.cfm needs to look like this

<cfcontent type="image/gif" file="c:\images\#url.image#">
Sorry for the long post but I don't see any other way to explain this and you're probably assuming I'm more experienced than I am. The main problem is that I'm not seeing where the name of the image change would take place. But I have other problems with your suggestions:

I don't see how using "randRange" will work. The image names would be random and would change at each return to the page.  This would not promote a good search engine index. Both image names and page keywords have to remain constant, and the same. When the search engine bots return, the image needs to be the same as it was, or the page will be needlessly reindexed, over and over. This causes problems with the search engines. They'll stop indexing if the page changes constantly. And it will also cause other problems.

In your suggestions, either of them, where does the image name get changed? That's the gist of what I need to understand and is where I really need the help. If you would please discuss that part it would help me, I'm sure.

If it helps us to use the same terms, then let me state that on each page, the keyword variable is "#meta_keyword#". Again, that's a comma delimited list, sometimes large, of popular keywords designed specifically for that page, and only that page. They populate the page in an orderly way, not random.

As I said before, I prefer not to use cfcontent, unless someone can suggest it won't be a problem. I'm very worried that cfcontent would be too much overhead for coldfusion, which is already a bit sluggish. On the average these images are about 6k in size. All thumbnail images are served to anyone accessing the system, completely open, and there are 30 images per page, tens of thousands of pages, and sometimes perhaps in excess of 2000 to 4000 images served each minute. That cannot change.

But above and beyond all that, I am not seeing where you are suggesting the name change would take place. The meta_keywords list has to be the reference for the new names of the images. I can see where you suggested to use a random name, and using my meta_keyword variable, I could do this:

<img src="/image.cfm?image=#meta_keyword#&random=#randRange(1,100)#" />

If this idea was used, a random number wouldn't be needed, just a sequential number, from 1 to 30.  But again, I am not seeing where the name change is taking place. Once I understand that from your suggestion, then perhaps I can figure it out.

So, can you help me here? Show me, in your suggestions, where the name change would take place and in a way where I can use the meta_keyword variable. Please explain this in a bit more conversational detail.

Or if anyone else who can see what I'm missing and point it out clearly, and share the points. Thanks so much for your help. This is very important to me and I'm way behind so I really need to understand.
Ok,

To fully understand what you are doing. Can you provide me with a couple examples of

1. site names
2. image names
3. other attributes

where these are all the same image.

So for example. If you have 3 sites show me the name of the site and what the images would be called for each 3 and anything other that's appropiate.
Okay, that sounds good. I can't post the actual domain names here but I will give three examples:

www.abc.com/nano/dvd-titles1.htm
www.def.com/sedmap/dvd-movies1.htm
www.ghi.com/plank/new-dvd-movies1.htm

The words in the URL, nano, sedmap, plank, mean nothing special. They are pseudo names and what we call Area Words.  A cfquery looks up the Area to find that each of those pseudo names point to a page Area titled "DVD MOVIES". There are as many pseudo names for "DVD MOVIES" as there are websites. The names were carefully chosen to mean nothing or very little so that people would not be too confused but that each website would have a different URL but the same content.

The rest of the URL (after the Area Word) can be any alpha character and the URL will still resolve. Any number in the URL after the Area Word, and the system assumes we need to display that page number. The Area Words could have been designed to use popular keywords but it wasn't. Maybe later. But first the thumbnail image names.

Here's an example of how the pages work for one example domain:

www.abc.com/nano/dvd-titles9.htm

For this website, the Area Word "nano", points to the Area "DVD MOVIES" in the database table, (more precisely, File Area 2087, Title DVD MOVIES).

Notice that in this example there is a "9" in the url (dvd-titles9.htm). This instructs CF to display the ninth page in the "DVD MOVIES" Area. If the page does not exist, nothing happens. Each page has 30 thumbnails so there are 30 filenames to mask with the keyword for that page.

The pages, dvd-titles1.htm, dvd-movies1.htm, new-dvd-movies1.htm, all point to the same page, the same content. It just looks different, all based on the meta_keyword variable from the meta_keywords list created for that page. There may be 50 to 200 keyword for each page, all designed to relate the the Title for that File Area, or for that page.

Thumbnail image and paths are set this way:

<cfset thumbpath = "http://www.#WebsiteInfo.DOMAIN#/thumb/#Replace(ListRest(FilesInfo.FILEPATH,"\"),"\","/","all")#">
        <cfset newfilename = ListFirst(FilesInfo.FILENAME,".")>
        <cfset thumb_ext = "#REReplace(Right(FilesInfo.FILENAME,3),"[^0-9]","","ALL")#.#ListLast(FilesInfo.FILENAME,".")#">

Except for a few minor bugs, this all works okay now. I just need to change the filename of the thumbnail image to vary the same as the meta_keyword variable for that page. The variable is readily available so we don't have to visit that bugger ...

Hope that helps. If you'd like to see more code, just yell.
So you can do something like this.

<cfset thumbpath = "/image.cfm?site=#WebsiteInfo.DOMAIN#&image=#FilesInfo.FILENAME#" />

Then in your image.cfm

serve back the image in url.image

Using something like

<cfcontent type="image/gif" file="c:\images\#url.image#">
I've said from the beginning that I prefer not to use cfcontent because I'm weary of the overhead to Coldfusion but you keep suggesting I use it. CF is being taxed heavily already. On my second paragraph, in my first post I wrote:

> I'd prefer not to use cfcontent or cflocation because of overhead issues.

Did you read the reason I'm worried, that is, in regard to the amount of images which would have to be served per minute by cfcontent? I gave some examples of the amount of images per minute which would have to be served and they are in the thousands per minute.

If you honestly believe that cfcontent would not be an overhead issue, please let me know and I'll look more closely at your suggestion. But from previous attempts to use cfcontent for another use, a couple years ago, cfcontent was, by far, too much overhead.
Assuming you have no ideas other than cfcontent to get this to work, I'm jumping ahead here a bit and decided to run a test using cfcontent.  I added this single line of code to the File Area page:

<img src="image.cfm">

There is one line of code in image.cfm:

<cfcontent type="image/jpeg" file="c:\server\test.jpg">

Note that I did not pass any variables because for this test I hard-coded the path and filename into the cfcontent tag.

However, the File Area page does not display test.jpg. When looking at the File Area page source, all I see is:

<img src="image.cfm">

There is no reference to an image. No matter what combination I use, the result is the same. There is no image display.

And for another test, I used cfcontent on the File Area page directly, just to see what I could achieve:

<cfset newthumbpath = "#Replace(FilesInfo.FILEPATH, "\\FileServer\d\", "c:\server\thumbs\d\","ALL")#">
<cfset newthumbpath = "#newthumbpath##newfilename##thumb_ext#.JPG">

<cfcontent type="image/jpeg" file="#newthumbpath#"></A>

I double-checked that newthumbpath was the correct full DOS path to the file. Cfcontent displays the first image out of 30, but only that one image, and nothing else on the page.

And of course, I'm still not able to see how I can change the image name using the meta_keyword variable. Nothing seems to work.

Again, I prefer not to use cfcontent this way, but I can't get close for a decent test.

Any ideas?




ASKER CERTIFIED SOLUTION
Avatar of Plucka
Plucka
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Well, you're the expert so if I’m smart, I’ll take your advise and go with it.  That's all I had to know.

So, yes, I'll give CFCONTENT another try. But you've spent a good amount of time on this so let me close it, award you the points, and I'll create another question for another 500 points you can answer. I'm sure you're not that interested in the points and mainly want to help, but I feel conscientious today. So, thanks, and please look for my new question
I've created another question so we can begin fresh.

https://www.experts-exchange.com/questions/21916122/How-can-I-use-CFCONTENT-to-mask-an-image-filename.html

But I have to tell you Dale, that if you had told me up front the only way to do this was with CFCONTENT, we both could have saved lots of time. Especially me.

And my not understanding your suggestions could be directly related to the amount of time you take to explain them. I'm sure you're busy and want to rush though the answer as fast as you can, so you can get to as many other questions as you can, to help others. In this question, that cost us both time.

I've done my best, taken lots of time to explain but with very little explanation in return, even though I asked for it. You can't fault me for not understanding.  That's why I'm here. If I was more experienced, I'd have no need to walk on egg-shells, being very careful to always be diplomatic (too late), just so I don't annoy the expert.

I closed this question even though all I got was that cfcontent has to be used, awarded the points, created another question. I hope you'll take the time to be gentle and explain your suggestions in a bit more detail when needed. My time is also valuable.

I do appreciate your help.