• Resolved yessirmr

    (@yessirmr)


    Hello,

    I am currently using the following code:

    [mla_gallery order="DESC" post_mime_type="image/webp" post_parent="all" link="none" itemtag="none" icontag="none" captiontag="none" size="large" posts_per_page="2" attachment_category="For Kids"] mla_caption='<div> <a href="{+parent_permalink+}" target="_blank" rel="noreferrer noopener"> <img src="{+file_url+}" alt="{+title+}" /></a><p><a href="{+parent_permalink+}" target="_blank" rel="noreferrer noopener">{+title+}</a></p></div>'[/mla_gallery]

    For some reason, the gallery is displaying two images.

    1. If I click on the small image, it takes me to the attachment page. Below it, there is a title that correctly points to the parent URL. The small image has the correct ALT attribute.

    2. The large image points to the parent URL, and its title also points to the parent URL. However, the ALT attribute for this image is incorrect—it displays the title of the image instead of the ALT attribute set in the back end.

    What am I doing wrong? I only need one image that meets the following requirements:

    Clicking the image takes me to the parent post.

    The title also takes me to the parent post.

    The ALT attribute matches the one set in the back end for this image.

    The image should display in the “large” size.

    Thank you for your help in resolving this issue!

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter yessirmr

    (@yessirmr)

    Hello,

    Please disregard my previous post the only problem is that i have now is that the image is not linking to parent post, instead it links to attachment page. The title is linking correctly.

    What I am doing wrong?

    [mla_gallery order=DESC post_mime_type=image/webp post_parent=all link=file itemtag="div" icontag="span" captiontag="p" size=large posts_per_page=2 attachment_category="For Kids"] mla_target="_blank" mla_link_attributes='rel="noreferrer noopener"' mla_caption='<a href="{+parent_permalink+}" target="_blank" rel="noreferrer noopener">{+title+}</a>'[/mla_gallery]

    Thank you in advance!

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your posts and your progress in developing your shortcode. Thanks as well for posting the complete shortcode text; very helpful.

    You can complete your shortcode by adding one more parameter:

    mla_link_href='{+parent_permalink+}'

    This parameter will replace the default attachment page/file link with the URL of the parent post.

    I am marking this topic resolved, but please update it if you have any problems or further questions regarding the above suggestion. Thanks for your interest in the plugin.

    Thread Starter yessirmr

    (@yessirmr)

    Hi David, thank you for your response, works great!

    Such a great plugin, I have sent a donation for it!

    One more question.

    How can I add image without any link(url) from the image and also from the title? What should the code look like??

    Best Regards,
    Janis

    Plugin Author David Lingren

    (@dglingren)

    Thanks for the good news regarding your progress and for the new question. You can remove the links from the [mla_gallery] display be replacing two of the shortcode parameters.

    First, replace link-file with link-none to remove the link associated with the thumbnail image.

    Second, replace the mla_caption parameter with this value:

    mla_caption='{+template:({+title+}|{+name_only+})+}'

    You could simply use mla_caption='{+title+}' but this template will use the name portion of the image file in the unlikely event that the Title is empty. You could substitute alt_text or post_excerpt (the caption) for name_only if you like.

    Let me know if you have problems or further questions regarding the above suggestions.

    Thread Starter yessirmr

    (@yessirmr)

    Hi David!

    Thank you for your previous response, works great! I have one more question, how can I assign class to all image? So that I would have <img class=abc > for every image?

    Best Regards,
    Janis

    Plugin Author David Lingren

    (@dglingren)

    Thanks for sharing your progess and for the new question. You can assign a class to the gallery images by adding a parameter to your shortcode:

    mla_image_class='abc'

    The class will be added to a couple of classes already present for the images. The original class attribute is class="attachment-large size-large", so the new value will be class="attachment-large size-large abc". If for some reason you want to completely replace the existing class attribute you can use a different parameter:

    mla_image_attributes='class="abc"'

    You can find more information about the mla_image_attributes and mla_image_class parameters (and others) in the “Gallery Display Content” section of the Settings/Media Library Assistant Documentation tab. Let me know if you have problems or further questions regarding the above suggestions.

    Thread Starter yessirmr

    (@yessirmr)

    Hi David, thank you for your response.

    I tried both ways but I get the class all the time in the div section

    div class="attachment-large size-large abc ">
    <img decoding="async" aria-describedby="mla_gallery-2-1072"

    What I want to achieve is to add class inside the <img parameter like this:

    div class="attachment-large size-large ">
    <img class="abc" cdecoding="async" aria-describedby="mla_gallery-2-1072"

    Is there any way I can do this?

    Best Regards,
    Janis

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update with the results of adding the mla_image_class parameter to your shortcodes. I had a look through your site and found an example of the problem in the “Coloring Pages” gallery.

    The standard WordPress HTML generated by the link=file parameter includes a hyperlink tag surrounding an image tag. Your site has some sort of Pinterest wrapper with a “dpsp-pin-it-wrapper” div tag surrounding the image tag. This additional layer is confusing the logic MLA uses to find and update the class attribute, giving the results you mentioned in your post.

    I will try to update the MLA logic to more carefully find and update the correct class attribute. This will take some time and I will post an update when I have progress to report.

    In the interim you might have better luck with the alternative parameter I mentioned. Try replacing the mla_image_class parameter with something like this:

    mla_image_attributes='class="entered lazyloaded abc"'

    That should add the abc class to the two class values I found in your gallery images. Let me know if that corrects the problem. Thanks for alerting me to this MLA defect.

    Thread Starter yessirmr

    (@yessirmr)

    Hi David, thank you for your response.

    I now added the code and I have this result

    <div class="dpsp-pin-it-wrapper entered abc  ">

    <img class="lazyloaded"

    any advise?

    Best Regards,
    Janis

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your update, I regret that the alternative I gave you did not resolve the problem.

    I have released MLA version 3.24, which contains updated logic for applying the mla_image_class parameter. The update should resolve the problem.

    Thanks for your patience while I developed the fix. Let me know if you have any problems with the new MLA version.

Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.