Can I Customize Images on a Website?

  • Thread starter Thread starter mattmns
  • Start date Start date
  • Tags Tags
    Websites
AI Thread Summary
Replacing icons on Physics Forums with custom images is technically possible but involves complex steps and potential challenges. Users can redirect image requests to their local server by modifying the hosts file and setting up a web server, though this approach may be resource-intensive and inefficient. Alternatives include using browser extensions like Greasemonkey to change images on the site, but there are limitations, especially with local file access due to security restrictions in browsers. For images hosted online, users can successfully replace them using JavaScript. Additionally, utilizing the forum's RSS feed could allow for more dynamic content customization, although current issues with the feed's validity may hinder this approach. Overall, while customization is feasible, it requires technical knowledge and may not yield significant benefits.
mattmns
Messages
1,121
Reaction score
5
Is it possible to replace, let's say, some of the physicsforums icons with my own? Maybe have pf look at cache first, and then replace the images with my own?

I guess I know it is possible, just is it easy to do? Danke.
 
Computer science news on Phys.org
Phew! are you sure You want to do it! I mean.. PF is not going to give u access for that!
 
Well, you could like redirect all requests to https://www.physicsforums.com/images/ to 127.0.0.1 (localhost), by editing the hosts file, set up a webserver on your own computer, download all images from PF and replace whatever ones you want to replace. More like a waste of cpu and memory if you ask me.
 
Last edited by a moderator:
mattmns said:
Is it possible to replace, let's say, some of the physicsforums icons with my own? Maybe have pf look at cache first, and then replace the images with my own?

I guess I know it is possible, just is it easy to do? Danke.

el-half gave what I think would be the easiest way. However still seems like a pain for little gain. Our graphics aren't that bad are they? :-p
 
Last edited:
Hmm looks like a pain I guess.

The graphics are not bad, I have gotten used to them, but I of course would like to be able to change them, or anything, to how I want it to look.

edit...
One of the ways I was thinking was to have the website code downloaded, then edit all instances, of say http://www.website.com/images/image.gif to file:///home/matt/images/image.gif
 
Last edited by a moderator:
I think you can change websites with firefox.
 
I was thinking about that too. But I only know how to remove objects with firefox, not change or add, going to do a quick search and see what comes up. Do you have any more info about that?
 
I know there is a firefox extension that does this. I read about it not too long ago. I'll have to look it up.

[edit] I found it!

http://greasemonkey.mozdev.org/
 
Last edited:
Thanks dduardo, checking it right now :smile:

edit... Wow! That extension is awesome! I have not changed any images on sites yet, but they have some really cool, and useful, scripts!
 
Last edited:
  • #10
Ok I can change images, but I only know how to change ones that have an id. How do I select an image that just has a source?

I used this to change images with an id, but many sites do not have ids for their images, any ideas?

Code:
(function() { 
document.getElementById('ID of image').src="location of image"
})();
 
  • #11
Your making it more difficult than it has to be. You can do something like this:

Code:
ChangeReplyButtons() {
for (var i=0; i < document.images.length; i++) {
if(document.images[i].src=="images/buttons/reply.gif") {
document.images[i].src="/home/david/myreply.gif" ;
}}}

You can add more if statements to change all the buttons. Isn't Javascript/DOM nice. I suggest you use the DOM inspector that comes with Firefox to help you.
 
Last edited:
  • #12
Thanks. I have the dom inspector installed, I guess the next step is to learn how to use it :smile:

Also, I am assuming from your response that I do not have to enter "file:///" before "home."
 
  • #13
You may or may not have to put file:///blah/blah/blah. When I type /home/dduardo into the browser it automatically resolves to file:///home/dduardo. Try it and see. Also remember that I'm on a linux system so on windows I don't know how this would work.
 
  • #14
Well I am on linux too :smile:

It does not when I enter a specific location of an image that has dashes in the name, it may be something else.

edit... and it does not seem to be working

This is mines.user.js
Code:
ChangeMinesweeperPics() {
for (var i=0; i < document.images.length; i++) {
if(document.images[i].src=="file:///home/matt/minesweeper-beg-5.png") {
document.images[i].src="file:///home/matt/minesweeper-int-33.png" ;
}}}

This is minetest.html
Code:
<html>
<title>testing</title>
<head>
</head>
<body>
<img src="file:///home/matt/minesweeper-beg-5.png" />
</body>
 
Last edited:
  • #15
It may be me, not even my yahoo script is working now :mad:
 
  • #16
I just created a simple script that replaces an image and it works just fine. Here is my code:

test.user.js
Code:
for (var i=0; i < document.images.length; i++) {
if(document.images[i].src=="file:///home/dduardo/flowchart.bmp") {
document.images[i].src="sales_tax.png" ;
}}

test.html
Code:
<html>
<body>
<img src="flowchart.bmp">
<img src="sales_tax.png">
</body>
</html>

[edit]Actually, I just realized why your script doesn't work. Your just declaring the function but not actually running it. :smile: :smile:
 
  • #17
ROFL. You were right, it works now. Thanks
 
  • #18
Yay!

It officially works on pf.

http://img172.exs.cx/img172/2250/pfscreenshot4mj.png

Now to add some real images :smile:

Thanks!
 
  • #19
Ok I am beginning to think that this will not work. I am only able to replace the images with other images on the pf website.
 
  • #20
Are you sure?
 
  • #21
I am never sure :smile: But I have not been able to get it to work with images from other websites, or images from my computer.
 
  • #22
I found the problem:

For security reasons, Mozilla does not allow web content to link to local files. An error like:Security Error: Content at url may not load or link to file:///something will appear in the javascript console. If you need to follow links to local paths it is recommended that you drag the link to the location bar and then drop it on the webpage. If you really don't like the security check and are willing to risk all files on your system and that your system can access then you may add the following line to user.js in your personal profile directory. user_pref("security.checkloaduri", false); (Bug 84128)

You can change the image with one on the net.
 

Attachments

  • test.png
    test.png
    2.9 KB · Views: 401
Last edited:
  • #23
You could also use PF's RSS feed, along with a webserver, to generate pages that look like anything in the world, but contain content from PF.

- Warren
 
  • #24
Huh, why I be darned, there is an RSS feed. The button is so small you wouldn't even know it was there.

If you wanted to go down this route you could write a really simple python script that uses libxml2 and libxslt to generate a xhtml file based on the xml file you get from this site and your own xsl (xml stylesheet) file. Of course you'll need a running apache server.

[edit] Actually it looks like the RSS feed is broken. Firefox is complaining that it isn't vaild xml.
 
Last edited:
  • #25
Yeah it seems like RSS is temporarily broken. I've told Greg about it -- I don't know what the deal might be. We'll get it back up soon.

I personally think using the RSS/XML feed is the simplest and best way to do it.

- Warren
 
  • #26
Looks like one of the thread titles is breaking the RSS feed. I will investigate.
 
  • #27
Boy o boy!
i never knew that was possible. Nice anyways. but i haven't got how actually the dyanmically changing webpage be kept modified.
 
Back
Top