Show off a font-awesome icon overlapping another image

My task involves fetching image source from a JSON file and then displaying it on an HTML page.

https://i.sstatic.net/coOaU.png

I also need to overlay a Font Awesome icon on top of the image as shown below:

https://i.sstatic.net/nbrLk.png

https://i.sstatic.net/yYha7.png

However, when I tried to implement the code for this feature, I encountered an issue where the Font Awesome icon was not displaying properly.

html

<link 
href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"
rel="stylesheet" type='text/css' >

script

$(document).ready(function() {
            var maskedImageUrla = "";
            var fontawesome = "<i class='fa fa-user-plus fa-2x'></i>";

            $.getJSON('test.json', function(json) {

              if (tl.src)
               {
                 maskedImageUrla = 'http://sitename.com/images/' + tl.src;
               }

                        var mask1 = $(".container").mask({
                            maskImageUrl: maskedImageUrla,
                            fontawesome: fontawesome,
                            onMaskImageCreate: function(img) {}
                        });
}); // end of document ready

Here is json file

Here is https://codepen.io/kidsdial/pen/bZNNXJ

Update: Code Snippet has been added below...

Your updated JS code snippet here
Your updated CSS code snippet here
Your updated HTML code snippet here

Answer №1

It appears that you have found the desired outcome

var mask1;
 
$(document).ready(function()
{
    var maskedImageUrla = "";
    var fontawesome = "<i class='fa fa-user-plus fa-2x'></i>";
    var coordinates = {
        x: 0,
        y: 0
    };
 
    var width = 0; var height = 0;
 
   var json = {
  "path" : " love shape\/",
  "info" : {
    "author" : "",
    "keywords" : "",
    "file" : "love shape", 
    // other properties...
    
  },
  "name" : "love shape",
  "layers" : [
    {
      // layer details...
      
    }
  ]
};
   
   
   
        for (let layer of json.layers)
        {
            // iterate through layers to extract necessary data
        }
 
        $(".container").css('width', width + "px").css('height', height + "px").addClass('temp');
 
        var mask1 = $(".container").mask({
            // set up mask properties and functionalities
        });
 
        // handle file upload change event
        fileupa1.onchange = function() {
            mask1.loadImage(URL.createObjectURL(fileupa1.files[0]));
        };
    
 
}); // end of document ready</answer1>
<exanswer1><div class="answer accepted" i="54898833" l="4.0" c="1551235656" a="TWFudSBKb3NlcGg=" ai="4213220">
<p>I trust this is the solution you have been searching for</p>

<p><div>
<div>
// other code snippets involving masks, CSS styling, jQuery, etc.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for managing JavaScript within PHP code and vice versa

Usually, I include a lot of JavaScript on the website. However, the client informed me that they were unable to view the website correctly as they had disabled JavaScript on their end. After investigating, I discovered this issue. Now, my dilemma is wh ...

Attempting to adjust the width of a text animation loaded with jQuery using Textillate, but encountering difficulties

I found a captivating animation on this website: http://codepen.io/jschr/pen/GaJCi Currently, I am integrating it into my project. #content { position: relative; margin-left: auto; margin-right: auto; width: 1000px; height: 700px; } ...

The jQuery fadeOut function modifies or erases the window hash

While troubleshooting my website, I discovered the following: /* SOME my-web.com/index/#hash HERE... */ me.slides.eq(me.curID).fadeOut(me.options.fade.interval, me.options.fade.easing, function(){ /* HERE HASH IS CLEARED: my-web.com/index/# * ...

Cleaning incorrect JSON formatting in a Python script

After receiving a JSON file containing data from an SQL database, I need to analyze it. The structure of the data resembles tables in the database, but when received, it appears like this: {'TimeStamp1': '2018-06-03 00:21:04', 'Ow ...

Sanitize input data prior to using express-validator in a Node.js application

In my Node.js project, I am utilizing the V4 syntax of express-validator as recommended: const { check, validationResult } = require('express-validator/check'); const { matchedData } = require('express-validator/filter'); Additionally ...

Is it a common issue for JSON/JQuery requests with a setTimeout to consistently return a "null" result when using the Twitter Search API?

Upon making a call to the Twitter API, I retrieve 100 posts along with properties indicating the next page to be called. However, when I wait 5 seconds and make that subsequent call, the JSON results in the callback function always return null the second t ...

Is there a way to achieve this design using bootstrap?

I am aiming to create a layout similar to this. My goal is to have a fixed sidebar on the left that measures 330px wide. Additionally, I want a gray box positioned at the center of the screen that adjusts its position based on changes in the content above ...

Modifying the jquery cookie's value

As soon as a user lands on my site, a persistent cookie (x1st) is set with a unique value (such as 'hdflashfafafxx233ddd'). This particular cookie is utilized for tracking purposes. However, if the user chooses to opt out of tracking cookies, I ...

My SF2 app is experiencing issues with AngularJS integration

I am currently developing a straightforward API using Symfony2 and now I am experimenting with integrating AngularJS into my bundle to visualize the results of my API calls. How can I effectively implement AngularJS? I initiated a bundle via app/console ...

The current status of Dropzone.js is in a pending state, preventing the upload of any

I have integrated Multer in the back-end for file upload handling and Dropzone.js in the front-end. Testing my back-end code with Postman works perfectly, but when using Dropzone, the status remains pending and the file does not get uploaded. After waiting ...

Arranging a child element within a parent element by placing the child div on the right side of the parent div

I am struggling with positioning a child .div containing rotating images to the right side of its parent (header) .div. I am utilizing the flexbox model for layout purposes. Despite my efforts, the solutions I have come across so far have not yielded the ...

Guidelines for callbacks and the impact on scope

I am currently diving into the world of scopes in angularjs, specifically when it involves calling callbacks on the module utilizing a directive. I have discovered three different methods to achieve the same goal and I am attempting to comprehend the advan ...

What is the advantage of using event.target over directly referencing the element in eventListeners?

Suppose there are several buttons in an HTML file and the following code is executed: const buttons = document.querySelectorAll('button'); buttons.forEach((btn) => { btn.addEventListener('click', (e) => { console.log(btn.te ...

What is the best way to assign multiple values to certain elements within an array?

I have an array that looks like this: items = { item1: 10, item2: 5, item3: 7, item4: 3, }; I am looking to include additional details in this array, for example: items = { item1: 10 {available: true}, ...

Struggling to send information using Angular $resource?

I've been working on sending data to an API using Angular's $resource. Currently, I can successfully retrieve data from my test server using a GET request or querying. However, I'm having trouble figuring out how to send new data to the serv ...

"Introducing a smooth animation effect to shift text alignment to the center

I'm currently using the code below, but I am not satisfied with the margin adjustment achieved by text-align:center;. Is there a way to smoothly transition the text alignment to center similar to how it is done in the following snippet of code? if ($ ...

Is it possible to minify HTML in PHP without parsing JavaScript and CSS code?

After finding a solution in this discussion, I successfully managed to 'minify' HTML content. function process_content($buffer) { $search = array( '/\>[^\S ]+/s', // eliminate spaces after tags, except for ...

Looking for assistance with aligning a form in the center?

After spending the last hour trying to center a form for a name without success, I have decided to seek help here. Although I have searched extensively, I am still struggling at this point. Here is my HTML: <div id="main" class="main"> <tabl ...

The website is experiencing display issues when viewed on Internet Explorer 10 and above

I am currently managing a few websites running on aspx with an older version of DNN 4.x. While these sites display properly on Google Chrome, Fire Fox, Opera, etc., I have noticed that there are rendering issues specifically on IE 10 and above for the navi ...

Choose an image depending on the title, but only if a specific condition is met

var no_images2 = $j("img[title^='Click to enlarge image no_photo']").parent(); $j(no_images2).css('pointer-events','none'); var no_images3 = $j("img[title^='Click to enlarge image no_photo']").parent(); $j(no_images ...