Any way to rename image filenames? - image

Is there any way to make the "image" module store files under a new name on upload? Basically, someone could upload a file that says something like "macs are cool" or something equally absurd. Now, I don't want people to see that. I'd much rather have all the files renamed on upload to something like: "111494949478383.jpg". How would I go about accomplishing this?

The FileField Paths module should do what you want. It works with both core Upload, as well as the FileField and Imagefield modules. You may also want to check out Imagefield Tokens, which allows the use of node tokens in things like the default alt text for images.

You can use the module "filefield Paths", and put in the filename [raw] that way the uploaded picture will have the node's timestamp creation time.
Also you can use [raw]_[filename].[file-extension] or whatever combination you can use, take a look at "file name replacement patterns"

with hook_nodeapi you could move the files and rename the images when the node is saved.
Or you could add something to the image upload callback with hook form alter to rename the image once it has been uploaded

yep, form_alter is the way to go for this

there are file modules that basically use tokens to do this
edit also imagefield supports tokens http://drupal.org/node/152640
immagefield could be better in long run if cck going to Drupal 7
hope that helps

Related

Is there a way I can use a different extension than .txt such as .log or .csv when using ApprovalTests?

I want the content to remain a text file, so code such as:
Approvals.Verify("some actual result as text");
Should continue to work. But I would like the approval tests to write to a ..approval.csv file or a ..approval.log file instead of ..approval.txt file.
I looked through the code and I think I may need to create a custom IApprovalWriter, but I also notice that the ExtensionWithDot property is read/write, so I'm wondering how this can be set.
Does anyone know how to do that?
ApprovalTests.Approvals.Verify(WriterFactory.CreateTextWriter(text, fileExtensionWithoutDot));
or for your example:
Approvals.Verify(WriterFactory.CreateTextWriter("some actual result as text", "log"));
Happy Testing!

Rename image to random

I'm working on an image uploader and if a user uploads a image I want to change the image name to something unique.
Imgur also does this for example "11Z6nlI.jpg"
So how can I generate a unique combination? I was thinking of using a timestamp since but that will also causes problems when more users upload at the same second.
I hope you guys can help me, I'm working in PHP
Although sometimes clunky, GUIDs are a good way to generate unique strings. See here for a way to generate GUIDs within PHP.

ExpressionEngine: File Manager

I’m new to EE and trying to learn the basics. Some questions about the File Manager:
I upload a photo and put “cat, kitten” in the description. When I do a search for “kitten”, it finds the photo. But when I do a search for “cat”, I get nothing. Any ideas what’s going on?
The file metadata are: file title, file name, description, credit, and location. What if I wanted to add custom fields? How do I do that?
In the template files, how do I access a particular manipulation (I call this “rendition”) of an image? Say I define a rendition “thumbnail” to be 100x100. How do I access that particular rendition in a template?
Is there a way to randomize the file names of the files being uploaded?
After uploading an image and testing it against PageSpeed, it turns out that the image can still be optimized via losslessly compressing it. How can this problem be addressed?
Ah, the file manager. Not EE's brightest spot.
It would not surprise me if the search in the File Manager was not
very robust. I'd try more variations to narrow it down (what kind of
characters affect the results - commas, dashes, spaces, etc ... do
partial terms match?)
You cannot currently add custom metadata to files in the file manager.
Use this syntax: {field_name:rendition}, e.g.,
{my_image:thumbnail} (docs).
Nope.
EE just uses the GD library available in your PHP install to resize
images. If you want the highest possible optimization, you'll have
to do your image manipulations yourself.
Given your queries, I would suggest you have a look at Assets by Pixel and Tonic. It offers a far superior file management experience on most of these fronts.

Temporary image upload script?

Hey guys! i just want to know if you know any free image upload script where you upload your images temporary. I need the image files to be deleted over time.
There is no such a way/method/script. Write a code which delete image files once they are no longer needed.
Automatic?
No way, you can aways use like this simple example:
$id=(int)$_GET['id'];
$sql = "DELETE FROM imagens WHERE img_id=".$id;
$exe=mysql_query($sql, $conect);
if($exe) unlink($_GET['arq']);
mysql_close ($conect);
look, in a effective system, you need moore checks for a secure code :)

Image Upload Service - Image locations and Image Identifiers

I would like to create a image uploading service (yes, i am aware of imageshack, photobucket, flickr...etc) :)
I have seen only imageshack show the directory names ("img294", "1646") of where the image is located, in the same way - i would like to do this.
http://img294.imageshack.us/img294/1646/**jquerykd5**.jpg
1) Are there any security issues I should be aware if i take this implementation?
2) How do these sites come up with short unique identifiers ("kd5")?
Thanks all for any advice and help.
Well for starters, unless you would like the directory to be public, put dummy index.html files in there or just restrict access to public users for those directories.
As for the unique identifiers there are many ways of going about this... some of my favourite chunks of information to use:
UNIX time (if running a unix based server)
chunks of the md5 of the file
pseudo random numbers
piece of the original filename
With these and many other pieces of information at your fingertips it should be easy to prevent duplicate image names conflicting on your server as well, you can gather as many as you like and concatenate them into a string for the filename. The md5 can be placed in a database as well to aid in a method of duplicate image detection, which could save you disk space as well.
I can promise you they all use URL rewriting. This will help with security issues, too.

Resources