Hello,
It is important for SEO to have alt text and title text. however i am not finding any option to enable/disable it in media manger and there is no place to put those details.
what can i do in this case?
thank you in advance.
Hello,
It is important for SEO to have alt text and title text. however i am not finding any option to enable/disable it in media manger and there is no place to put those details.
what can i do in this case?
thank you in advance.
If you have control over the structure of your data, you can add a text field in the backend side for the text.
However, you could use the file upload widget. Every image that is uploaded using that widget has its own title and description that you can use.
Thank you @artistro08.
I am talking about Media Manager itself.
If you check the image i want to add some fields to the box in red.
Ahh okay.
That isnât supported and hasnât been supported for a long time.
If my memory serves me well, I know the founders are creating something to address that. I could be wrong tho
I think there is also not really a need for that. You can set those attributes when you place the image.
If youâre using the CMS Editor, you have control over the markup anyway. If youâre using the richeditor widget (with the static pages plugin or as a field for you model) you can set the alt tag with the button in the image context menu. And in other cases like repeater fields, models or Tailor blueprints you also have full control over what you want to be editable.
On the other hand, if you could set those attributes in the Media Manger, the Media Manager would need to be rewritten to be database dependent (or any storage method that can save those attributes) and the alt attributes will be wrong, or at least not perfectly suitable, when there are placed anyway.
One thing that would be nice though, would be a âDescribe & insertâ button, like the âCrop & insertâ button. This would make the placement and description a single step. But thats just a small inconvenience imho.
Simple: if you need alts/titles - use attachments (fileupload widget).
@marco.grueter you are absoulutely right.
USE CASE:
we are using configurations to upload an image. The relation would therefore be needed for this image. but the settingFields is unable to have any relationship in this case.
e.g
i am using this special model from OctoberCms
(https://docs.octobercms.com/2.x/plugin/settings.html)
Now there is an image field also in the Config. this only works when you have media image from Manager. But if i put file upload widget there should be a relationship to that particular key like the attachOne.
So may be i am wrong but having this problem.
i would like to put the field as file upload but then the problem is with the relation.
How you solve this? How can you put a config key as a relationship?
Thank you in advance
Yes, I saw your other post, but wasnât sure what the problem could be.
But now I saw the word âControllerâ in the error. Make sure your calling the right class. Looks like your trying to call your controller (called MySettingsController ?) when you wanted to use the model.
And, to be more in line with this discussion, you can always add more fields to your settings model to let the user configure the alt and description attribute or whatever you need. This way you could also use the media finder if this suits your need better and get the alt tags from a different field.
Thank you. Yes the controller Namespace is a typo here.
So you means extra two fields (title and caption) for the Media Upload Image right?
That would do the trick for sure.
More of a learning question:
would it be not nice to relates the config model key to an attachement?
e.g: letâs say i have an image key called f_image now i want to have the attachement for this image. is there any way i can relate this config key to an attachement?
like so
letâs say the
public $settingsCode = âmy_setting_codeâ;
and the field name is f_image
public $attachOne = [
âmy_setting_code[f_image]â => âSystem\Models\Fileâ
];
is there anyway to achieve this?
Thanks alot for your time <3
Ah yes, you can do that. You probably overlooked that the $settingsFields
member of the settings model takes a form fields definition, just like your other models.
example:
File: [namespace]/[plugin]/models/Settings.php
class Settings extends Model
{
public $attachOne = ['yourfile' => \System\Models\File::class];
/**
* @var string settingsCode unique to this model
*/
public string $settingsCode = 'my_plugin_settings';
/**
* @var string settingsFields configuration
*/
public string $settingsFields = 'my_settings_fields.yaml';
[ ... ]
File: [namespace]/[plugin]/models/settings/my_settings_fields.yaml
fields:
yourfile:
label: An image or something
type: fileupload
mode: image
[ ... ]
Seem to be working fine, Iâve just tested it on a OCM V2 latest installation (sorry, donât have a V3 handy at the moment).
One thing though: I think you will have the access through the instance, it might not be possible with the get
helper method. E.g.: YourSettingsModel::instance()->yourfile->path
instead of YourSettingsModel::get('yourfile')
Hope that helps!
@marco.grueter Thank you so much.
i guess i am very near to it.
This works: YourSettingsModel::instance()->yourfile->path
The relation is empty so there is this error now.
Attempt to read property "path" on null
Any thought on that how can i assign a dummy relationship before the fields?
I already tried
(https://octobercms.com/forum/post/call-to-a-member-function-hasrelation-on-null-error-message?page=1)
Thank you for your time. I really appreciate it.
Iâm glad to help you out, no problem. But I am unsure where you are stuck now.
If youâre asking if you can set default values for your settings model - you are in luck!
/**
* Default values to set for this model, override
*/
public function initSettingsData()
{
$this->yourfile = '/absolute/path/to/yourfile.jpg;
}
You can override this function in your settings model, to initialize your settings with default data.
Set them as a member variable or explicit with the helper functions.
Also check out the hints for creating file attachments at File Attachments - October CMS - 2.x
Cheers!
@marco.grueter thanks alot for helping me out.
I followed your tutorial. and used
YourSettingsModel::instance()->yourfile->path
in the formExtendFields Method to populate the form. now the hasRelation error is gone but getting a new error
Attempt to read property "path" on null
I am setting it like this
$form->getField('yourfile')->value = FellowzSettings::instance()->yourfile->path;
Forgive my ignorance but stuck in a small thing.
i tried in the Model
$file = new File();
$file->fromUrl('http://my.local/storage/app/media/logo_light.png');
$this->f_image->add($file);
but the error still persists.
@marco.grueter I finds the problem.
i am using a custom controller (i dont know why :P) but when i use the settings page. then all of a sudden i dont need a custom controller and all workd well.
Thanks alot for helping me out <3.
btw the controller method made me curious now
Hi!
I was browsing for this particular topic and while the discussion forked from the original issue, I was wondering if the problem was the right one.
I have the same issue but I would like to be able to add an âaltâ attribute in the MediaFinder - when the image is selected for something (in a Tailor blueprint in my case) - and not the MediaManager - where all images are upload and managed. Because, as pointed by @marco.grueter, the image in the MediaManager can be used anywhere and many times and therefore the âaltâ attribute might not be correct for all intents and purposes.
I tried to look at just extending the MediaFinder to add a field but itâs not that simple as it is only represented as a string and does not have other data than the pointer.
Any ideas in that direction?
To me, this is something that should be handled by the core team, as an octobercms evolution.
Because there is not only an alt problem, itâs, to me, a more global revamp that media management need.
First, having to choose between file upload and media manager depending on the use case is a result of a bad conception. When dealing with media in a modern CMS, adding meta informations, choosing different images depending on different breakpoints, edit image before choosing it (like pintura style editing) is what you expect with a modern CMS.
This part of octobercms need a complete revamp, or, at least, a complete new widget that would merge the best of both world.