Closed t2thec closed 9 years ago
Hi, T2theC. Thank you for your comment. Oh, adding attributes is a great idea.:)))
I don't have define idea yet but I'm considering to add attributes() method like the following.
->attributes([ 'img' => ['alt' => 'image_alt'], .... ])
I'll think a little more about it.
I appreciate your help. Have a good day!!
That's brilliant. My thoughts are that they should be saved with surpass_ids. That way you could use the same image in different posts but have different attributes - which could be better for seo. If it is saved with the image, then you lose a bit of control.
Thanks Sikhs. Have a good one!
Sorry! Autocorrect changed your name! Thanks Sukohi.
Hi, T2theC. At first, I likely misunderstood your idea a little.(Sorry!)
After all, I decided to add a function to the package that can save attributes when being called save() method like this.
$attributes = array('alt' => 'alt_value', 'title' => 'title_value');
if($surpass->save($attributes)) { // Something.. }
And now, we can retrieve the attributes (and image-tag) like this.
$attributes = $load_item->attributes; $tag = $load_item->tag;
Thank you again.:)))
Thanks Sukohi. That sounds awesome. I'll have a play shortly. So is there a way to manually change the attributes? How would I create and 'alt' or 'title'?
If I upload an image to /upload and it is saved, Can I then make changes to the attributes?
I am starting to think I missed something. Are there any views that should be published? I have published as per your example, but nothing in /public/packages - I'm guessing this is just for the JS and HTML?
Thanks again.
Oh, so sorry! I forgot to say something. I guess you need to execute the next command because I added new column called "attributes" to the table.
php artisan migrate --package=sukohi/surpass
By this command attributes column should be added through the new migration.
If you'd like to change "attributes", you can use DB or Model(Elequent) as usual like this.
DB::table('image_files') ->where('id', 1) ->update(array('attributes' => json_encode(array('alt' => 'value'))));
or
After making a model file for "image_files",
$image_file = ImageFile::find(1); $image_file->attributes = json_encode(array('alt' => 'new value')); $image_file->save();
Note: Attributes data must be json (or empty);
I could add update() method, if I need it in the next development.
Thank you.:)))
Hey. Just wondering if there is a way to easily add custom fields to the preview image? It would be great to add alt tags, title tags and perhaps a URL tag so it can be used for banners etc. perhaps 'surpass_ids[]' could become a multi dimensional array? Or preview_images could be extended?
Thanks for building the package. Awesome.