I’m interested in finding out if the Image Link button can be added to the comment buttons when employing the comment buttons plugin which really just seems to piggy back off of html_buttons.php?
In html_buttons.php under the “create_buttons” function there is
if ($this->allow_img == TRUE)
{
$this->buttons[] = array("<img>", "[img]", "[/img]", "Image Link");
}
which seems to indicate that it should be possible to see this button when using the comment_buttons plugin along with enabling “image links” for comment entries.
When looking at html_buttons.php a bit more closely, even though the condition is set to establish and IMG button I don’t see a function actually making the image link (as is done in done for the buttons created in cp_publish.php.
Am I missing something or will I need to add this to make a fully functioning image link button?
Thanks
OK, so at the top of html_buttons.php there is a variable $allow_img which is set to FALSE by default.
Does the CP setting that enables “image links” for comment entries control this variable of if I want the IMG button do I need to set it manually in html_buttons.php?
Additionally, this process does not allow for a “alt” attribute to be included which throws errors when trying to validate the pages that images are added to using this button.
Hey Greg, ultimately yes. I’m probably going to be adding additional formatting features.
But, It seems that the <img> button produces an image tag that does not include an “alt” attribute. I’d like to update this but it looks like to do so I’ll need to follow the approach used to create both the “email” and “link” buttons ignoring the $allow_img setting (keeping it set to FALSE) and adding a new img tag function.
Understanding that the example below by itself will not establish a new button - but something like
//
// Image Button
//
if (which == "image")
{
var URL = prompt(image_text, "http://");
if ( ! URL || URL == null)
return;
var ALT = prompt(alt_text, theSelection);
if (ALT == null)
return;
if (ALT == "")
Title = Example;
var Link = '' + URL + ';
}
this logic stand to reason?
Michael:
In theory, yes, it makes sense, however I haven’t used the plugin you are referring to, so I can’t give a definitive answer. I going to move this down to the plugins forums, as it’s a better fit, and more likely to get some community feedback as well.
Kind Regards,
-greg
Wondering if someone might be able to help me understand a few things about how the html_buttons.php script functions.
Things I’ve noticed: 1) At the opening of the scrip under the create_buttons() (about line 19) function a series of arrays are defined for all of the buttons with the exception of 2, the email and link buttons which involve a prompt for input.
2) Though there is an array for an image tag defined in the create_buttons() function it too should probably require user input for the “alt” tag so the resulting output is valid.
3) At about line #379 it looks like the “link” functionality is established.
4) At about line #396 it looks like the “email” functionality is established.
How, when both the link tags and email tags are created with the formatting scheme that uses and [email=”ZZZ”][/url] is this converted to html tags? I don’t see how this these tags are converted? It looks like the arrays defined in create_buttons() include the html formatted tag.
Maybe I’m missing something very obvious. Just wondering if someone might be able to point out what I’m missing.
Thanks.
This is what I’ve been able to achieve thus far: To html_buttons.php around line #39 I’ve added a variable
var image_text = "Enter the image URL";
Around line #406 I’ve added the following function
//Add Image prompt
if (which == "image")
{
var URL = prompt(image_text, "http://");
if ( ! URL || URL == null)
return;
var Link = '[IMG]' + URL + '[' + '/IMG]';
}
This does seem to achieve what I’m after by prompting the user to input an image URL. Additionally, it looks as if the alt attribute is added dynamically and equal to the last segment of the image url provided (the file name).
So, now I’m left with trying to get this “video” embed button to work.
Around line #451 I’ve added the following function:
if (which == "video")
{
var VID = prompt(vid_text,"http://");
if ( ! VID || VID == null)
return;
var Link = '<!-- VIDEO --><object data="' + VID + '" width="425" height="344" class="margin_btm_10"><param name="movie" value="' + VID + '" ><a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">Install Flash Player to view content</a></object><!-- END VIDEO -->';
}
Additionally I’ve added the following variable at about line #46
var vid_text = "Enter the URL to the VIDEO";
And the html for the associated button around line #532
This does generate a new button with the “Video” label. When selected, it fires a JS prompt to provide a video url. Once provided and ok is clicked the associated code is added to the comment textarea. The trouble is, when the comment is posted, the html still renders as entities.
I’ve adjusted the comment posting properties to make sure HTML is allowed but this has no affect.
Any clues on how to address?
Thanks
@ContextDesign - ha…sorry I missed your post initially.
Unfortunately, no. I wasn’t able to achieve this. Part of this issue is that any solution requires know how that far exceeds my personal skill set. That said, the issue lies with core.typography.php.
I’m not at all certain that the hooks are available to achieve this but essentially a new formatting tag will need to be established and then converted similar to how the [img] tags are converted to the proper html.
So you wouldn’t actually be providing the video embed via the html buttons script but rather you’d just establish a video tag and have the user input the doc_id so the resulting tag might look like [video]doc_id[/video] which is then converted by the typography conversion. Problem is, it’s my understanding that there are some parsing order issues that exist on top of this which make this even more difficult - especially for my lowly designers intellect. :wow:
I’ve even sought out individuals, expressed my willingness to pay, but I’ve not had anyone bite.
I’ve also tried the Forum Video plugin because I was told it should work on comments. And, it does…sort of. But unfortunately, when the plugin is in play any comments with “formatting” applied no longer display the formatting properly. The tags just render as text.
Let me know if I can be of any more assistance, and if you’re able to achieve this…I’d love to see how it’s done.
Regards.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.