Answer the question
In order to leave comments, you need to log in
How not to overwrite pictures when saving?
Hello! It’s not the first week that I have been faced with a task, plz push me to the idea of an editing algorithm.
On the culinary site, the recipe has 3 steps, each with one picture. Each picture is called the name of the recipe (in transliteration) plus the step number:
/image/kurica_s_gribami-1.jpg
/image/kurica_s_gribami-2.jpg
/image/kurica_s_gribami-3.jpg
/image/kurica_s_gribami-2.jpg
respectively, the one that was under this name will be called /image/kurica_s_gribami-3.jpg
, etc. /image/kurica_s_gribami-2.jpg
, given that any step can be deleted in the same way, which means that it will be necessary to re-save in the opposite direction.rename(/image/kurica_s_gribami-2.jpg, /image/kurica_s_gribami-3.jpg);
the third picture will be overwritten.
Answer the question
In order to leave comments, you need to log in
Why is this a perversion? the step, as far as I understand, has its own id, so what prevents you from storing pictures with this id as a name?
IMHO it will be more convenient to store pictures in a separate recipe folder
not
/image/kurica_s_gribami-n.jpg,
but
/image/kurica_s_gribami/n.jpg.
And it's probably better to store the order in a separate field images_order - just listing the order separated by commas, like "1.png,2.png,10.png,5.png".
And then adding and removing is just a matter of technique.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question