News:

Looking for documentation? Take a look on our wiki

Main Menu

Why the weird Unique Filenames?

Started by neo314, November 29, 2012, 22:03:49 PM

Previous topic - Next topic

bytelord

Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

neo314

Quote from: bytelord on December 01, 2012, 21:28:57 PM
Hey neo,

The file_name value is empty when editing for that reason you get an exception. When uploading a new image then the file_type is not empty.

Is there that i was trying to explain the for sequence number creation you will need to create a function that will search the database for same file_name, retrieve an array from the db, compare, make a sequence number, validate it to be sure, placed on file_title.

At your code snippet $this->file_title = pathinfo($this->file_url, PATHINFO_BASENAME); i don't think will work, you will need something line
<?php


$this->file_title= basename($this->file_url); //will return filename.jpg for example
or
$this->file_title= basename($this->file_url,'.jpg'); // will return filename

or you can use explode or combination with substr

btw, never tested the above ... just write it here...

BUT, in any case each time you save your media file the file_title will be equal to file_name and you will not be able to edit the "value", so if is equal there is no reason to use it or to exist at all :) :)

Regards

I'm not sure why you think pathinfo won't work as it does the same thing as basename in this instance. I started with path name and the extension got cutoff without the suffix constant so I abandoned it.

Your right about it always being the filename. I just posted a work around for that, but as I suggested, I am not as familiar with the VM code yet and the best solution IMHO is for the "Unique Filename" property to not be passed from the form when the save button is clicked to upload a new file. In the meantime, this is a hack with consequences.

I'm not sure how many people are really using this alias feature to create complex names not in their filename structure, but I doubt anyone wants myimage.jpg_product_product_product or to have to edit the alias every upload. If there are a lot of people doing that though, a checkbox could be added to the form that would be a checkbox flag to force a new upload to have the alias of the filename, or an input field to provide the desired alias.

bytelord

Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

lindapowers

Note, even in version 2.022 this still happens.

jpg_product is added to second, third, fourth images for products even if they have unique filenames.

Regards